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
|
||||
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
|
||||
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], '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'); // 2
|
||||
```
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing averageBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
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.equal(averageBy(args..), 'Expected');
|
||||
//t.false(averageBy(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing maxBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
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.equal(maxBy(args..), 'Expected');
|
||||
//t.false(maxBy(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing minBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
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.equal(minBy(args..), 'Expected');
|
||||
//t.false(minBy(args..), 'Expected');
|
||||
|
||||
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
|
||||
> 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
|
||||
|
||||
√ averageBy is a Function
|
||||
√ Produces the right result with a function
|
||||
√ Produces the right result with a property name
|
||||
|
||||
Testing binarySearch
|
||||
|
||||
@ -837,6 +839,8 @@ Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
||||
Testing maxBy
|
||||
|
||||
√ maxBy is a Function
|
||||
√ Produces the right result with a function
|
||||
√ Produces the right result with a property name
|
||||
|
||||
Testing maxN
|
||||
|
||||
@ -861,6 +865,8 @@ Test log for: Wed Jan 24 2018 17:33:18 GMT+0200 (GTB Standard Time)
|
||||
Testing minBy
|
||||
|
||||
√ minBy is a Function
|
||||
√ Produces the right result with a function
|
||||
√ Produces the right result with a property name
|
||||
|
||||
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
|
||||
|
||||
|
||||
total: 621
|
||||
passing: 621
|
||||
duration: 417ms
|
||||
total: 627
|
||||
passing: 627
|
||||
duration: 419ms
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user