3
test/converge/converge.js
Normal file
3
test/converge/converge.js
Normal file
@ -0,0 +1,3 @@
|
||||
const converge = (converger, fns) => (...args) =>
|
||||
converger(...fns.map(fn => fn.apply(null, args)));
|
||||
module.exports = converge;
|
||||
23
test/converge/converge.test.js
Normal file
23
test/converge/converge.test.js
Normal file
@ -0,0 +1,23 @@
|
||||
const test = require('tape');
|
||||
const converge = require('./converge.js');
|
||||
|
||||
test('Testing converge', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof converge === 'function', 'converge is a Function');
|
||||
const average = converge((a, b) => a / b, [
|
||||
arr => arr.reduce((a, v) => a + v, 0),
|
||||
arr => arr.length,
|
||||
]);
|
||||
t.equal(average([1, 2, 3, 4, 5, 6, 7]), 4, 'Produces the average of the array');
|
||||
const strangeConcat = converge((a, b) => a + b, [
|
||||
x => x.toUpperCase(),
|
||||
x => x.toLowerCase()]
|
||||
);
|
||||
t.equal(strangeConcat('Yodel'), "YODELyodel", 'Produces the strange concatenation');
|
||||
//t.deepEqual(converge(args..), 'Expected');
|
||||
//t.equal(converge(args..), 'Expected');
|
||||
//t.false(converge(args..), 'Expected');
|
||||
//t.throws(converge(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user