Tests for averageBy, maxBy, minBy
Fixed examples in minBy
This commit is contained in:
@ -9,6 +9,6 @@ const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : v
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
|
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 2
|
||||||
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 8
|
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 2
|
||||||
```
|
```
|
||||||
|
|||||||
@ -5,9 +5,11 @@ test('Testing averageBy', (t) => {
|
|||||||
//For more information on all the methods supported by tape
|
//For more information on all the methods supported by tape
|
||||||
//Please go to https://github.com/substack/tape
|
//Please go to https://github.com/substack/tape
|
||||||
t.true(typeof averageBy === 'function', 'averageBy is a Function');
|
t.true(typeof averageBy === 'function', 'averageBy is a Function');
|
||||||
|
t.equals(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 5, 'Produces the right result with a function');
|
||||||
|
t.equals(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 5, 'Produces the right result with a property name');
|
||||||
//t.deepEqual(averageBy(args..), 'Expected');
|
//t.deepEqual(averageBy(args..), 'Expected');
|
||||||
//t.equal(averageBy(args..), 'Expected');
|
//t.equal(averageBy(args..), 'Expected');
|
||||||
//t.false(averageBy(args..), 'Expected');
|
//t.false(averageBy(args..), 'Expected');
|
||||||
//t.throws(averageBy(args..), 'Expected');
|
//t.throws(averageBy(args..), 'Expected');
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,9 +5,11 @@ test('Testing maxBy', (t) => {
|
|||||||
//For more information on all the methods supported by tape
|
//For more information on all the methods supported by tape
|
||||||
//Please go to https://github.com/substack/tape
|
//Please go to https://github.com/substack/tape
|
||||||
t.true(typeof maxBy === 'function', 'maxBy is a Function');
|
t.true(typeof maxBy === 'function', 'maxBy is a Function');
|
||||||
|
t.equals(maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 8, 'Produces the right result with a function');
|
||||||
|
t.equals(maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 8, 'Produces the right result with a property name');
|
||||||
//t.deepEqual(maxBy(args..), 'Expected');
|
//t.deepEqual(maxBy(args..), 'Expected');
|
||||||
//t.equal(maxBy(args..), 'Expected');
|
//t.equal(maxBy(args..), 'Expected');
|
||||||
//t.false(maxBy(args..), 'Expected');
|
//t.false(maxBy(args..), 'Expected');
|
||||||
//t.throws(maxBy(args..), 'Expected');
|
//t.throws(maxBy(args..), 'Expected');
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,9 +5,11 @@ test('Testing minBy', (t) => {
|
|||||||
//For more information on all the methods supported by tape
|
//For more information on all the methods supported by tape
|
||||||
//Please go to https://github.com/substack/tape
|
//Please go to https://github.com/substack/tape
|
||||||
t.true(typeof minBy === 'function', 'minBy is a Function');
|
t.true(typeof minBy === 'function', 'minBy is a Function');
|
||||||
|
t.equals(minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 2, 'Produces the right result with a function');
|
||||||
|
t.equals(minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 2, 'Produces the right result with a property name');
|
||||||
//t.deepEqual(minBy(args..), 'Expected');
|
//t.deepEqual(minBy(args..), 'Expected');
|
||||||
//t.equal(minBy(args..), 'Expected');
|
//t.equal(minBy(args..), 'Expected');
|
||||||
//t.false(minBy(args..), 'Expected');
|
//t.false(minBy(args..), 'Expected');
|
||||||
//t.throws(minBy(args..), 'Expected');
|
//t.throws(minBy(args..), 'Expected');
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|||||||
14
test/testlog
14
test/testlog
@ -1,4 +1,4 @@
|
|||||||
Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
Test log for: Wed Jan 24 2018 17:37:28 GMT+0200 (GTB Standard Time)
|
||||||
|
|
||||||
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
||||||
> tape test/**/*.test.js | tap-spec
|
> tape test/**/*.test.js | tap-spec
|
||||||
@ -41,6 +41,8 @@ Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
|||||||
Testing averageBy
|
Testing averageBy
|
||||||
|
|
||||||
√ averageBy is a Function
|
√ averageBy is a Function
|
||||||
|
√ Produces the right result with a function
|
||||||
|
√ Produces the right result with a property name
|
||||||
|
|
||||||
Testing binarySearch
|
Testing binarySearch
|
||||||
|
|
||||||
@ -837,6 +839,8 @@ Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
|||||||
Testing maxBy
|
Testing maxBy
|
||||||
|
|
||||||
√ maxBy is a Function
|
√ maxBy is a Function
|
||||||
|
√ Produces the right result with a function
|
||||||
|
√ Produces the right result with a property name
|
||||||
|
|
||||||
Testing maxN
|
Testing maxN
|
||||||
|
|
||||||
@ -861,6 +865,8 @@ Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
|||||||
Testing minBy
|
Testing minBy
|
||||||
|
|
||||||
√ minBy is a Function
|
√ minBy is a Function
|
||||||
|
√ Produces the right result with a function
|
||||||
|
√ Produces the right result with a property name
|
||||||
|
|
||||||
Testing minN
|
Testing minN
|
||||||
|
|
||||||
@ -1457,8 +1463,8 @@ Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
|||||||
√ zipWith is a Function
|
√ zipWith is a Function
|
||||||
|
|
||||||
|
|
||||||
total: 621
|
total: 627
|
||||||
passing: 621
|
passing: 627
|
||||||
duration: 417ms
|
duration: 419ms
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
const xProd = (a, b) => a.reduce((acc,x) => acc.concat(b.map(y => [x, y])),[]);
|
const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []);
|
||||||
module.exports = xProd
|
module.exports = xProd
|
||||||
Reference in New Issue
Block a user