Tests for flip, over, overArgs, pipeFunctions

This commit is contained in:
Angelos Chalaris
2018-02-04 16:54:49 +02:00
parent af0e163ec2
commit b1934902b0
5 changed files with 26 additions and 7 deletions

View File

@ -5,6 +5,11 @@ test('Testing flip', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof flip === 'function', 'flip is a Function');
let a = { name: 'John Smith' };
let b = {};
const mergeFrom = flip(Object.assign);
let mergePerson = mergeFrom.bind(null, a);
t.deepEqual(mergePerson(b), a, 'Flips argument order');
//t.deepEqual(flip(args..), 'Expected');
//t.equal(flip(args..), 'Expected');
//t.false(flip(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing over', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof over === 'function', 'over is a Function');
const minMax = over(Math.min, Math.max);
t.deepEqual(minMax(1, 2, 3, 4, 5), [1,5], 'Applies given functions over multiple arguments');
//t.deepEqual(over(args..), 'Expected');
//t.equal(over(args..), 'Expected');
//t.false(over(args..), 'Expected');

View File

@ -5,6 +5,10 @@ test('Testing overArgs', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof overArgs === 'function', 'overArgs is a Function');
const square = n => n * n;
const double = n => n * 2;
const fn = overArgs((x, y) => [x, y], [square, double]);
t.deepEqual(fn(9, 3), [81, 6], 'Invokes the provided function with its arguments transformed');
//t.deepEqual(overArgs(args..), 'Expected');
//t.equal(overArgs(args..), 'Expected');
//t.false(overArgs(args..), 'Expected');

View File

@ -5,6 +5,10 @@ test('Testing pipeFunctions', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof pipeFunctions === 'function', 'pipeFunctions is a Function');
const add5 = x => x + 5;
const multiply = (x, y) => x * y;
const multiplyAndAdd5 = pipeFunctions(multiply, add5);
t.equal(multiplyAndAdd5(5, 2), 15, 'Performs left-to-right function composition');
//t.deepEqual(pipeFunctions(args..), 'Expected');
//t.equal(pipeFunctions(args..), 'Expected');
//t.false(pipeFunctions(args..), 'Expected');

View File

@ -1,4 +1,4 @@
Test log for: Sun Feb 04 2018 16:47:24 GMT+0200 (GTB Standard Time)
Test log for: Sun Feb 04 2018 16:54:16 GMT+0200 (GTB Standard Time)
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
> tape test/**/*.test.js | tap-spec
@ -409,6 +409,7 @@ Test log for: Sun Feb 04 2018 16:47:24 GMT+0200 (GTB Standard Time)
Testing flip
√ flip is a Function
√ Flips argument order
Testing forEachRight
@ -1044,10 +1045,12 @@ Test log for: Sun Feb 04 2018 16:47:24 GMT+0200 (GTB Standard Time)
Testing over
√ over is a Function
√ Applies given functions over multiple arguments
Testing overArgs
√ overArgs is a Function
√ Invokes the provided function with its arguments transformed
Testing palindrome
@ -1095,6 +1098,7 @@ Test log for: Sun Feb 04 2018 16:47:24 GMT+0200 (GTB Standard Time)
Testing pipeFunctions
√ pipeFunctions is a Function
√ Performs left-to-right function composition
Testing pluralize
@ -1701,8 +1705,8 @@ Test log for: Sun Feb 04 2018 16:47:24 GMT+0200 (GTB Standard Time)
√ Works with multiple promises
total: 805
passing: 805
total: 809
passing: 809
duration: 2.4s