Tests for matches, matchesWith, mapValues
This commit is contained in:
@ -5,6 +5,11 @@ test('Testing mapValues', (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 mapValues === 'function', 'mapValues is a Function');
|
t.true(typeof mapValues === 'function', 'mapValues is a Function');
|
||||||
|
const users = {
|
||||||
|
fred: { user: 'fred', age: 40 },
|
||||||
|
pebbles: { user: 'pebbles', age: 1 }
|
||||||
|
};
|
||||||
|
t.deepEqual(mapValues(users, u => u.age), { fred: 40, pebbles: 1 }, 'Maps values');
|
||||||
//t.deepEqual(mapValues(args..), 'Expected');
|
//t.deepEqual(mapValues(args..), 'Expected');
|
||||||
//t.equal(mapValues(args..), 'Expected');
|
//t.equal(mapValues(args..), 'Expected');
|
||||||
//t.false(mapValues(args..), 'Expected');
|
//t.false(mapValues(args..), 'Expected');
|
||||||
|
|||||||
@ -5,6 +5,8 @@ test('Testing matches', (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 matches === 'function', 'matches is a Function');
|
t.true(typeof matches === 'function', 'matches is a Function');
|
||||||
|
t.true(matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }), 'Matches returns true for two similar objects');
|
||||||
|
t.false(matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }), 'Matches returns false for two non-similar objects');
|
||||||
//t.deepEqual(matches(args..), 'Expected');
|
//t.deepEqual(matches(args..), 'Expected');
|
||||||
//t.equal(matches(args..), 'Expected');
|
//t.equal(matches(args..), 'Expected');
|
||||||
//t.false(matches(args..), 'Expected');
|
//t.false(matches(args..), 'Expected');
|
||||||
|
|||||||
@ -5,6 +5,12 @@ test('Testing matchesWith', (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 matchesWith === 'function', 'matchesWith is a Function');
|
t.true(typeof matchesWith === 'function', 'matchesWith is a Function');
|
||||||
|
const isGreeting = val => /^h(?:i|ello)$/.test(val);
|
||||||
|
t.true(matchesWith(
|
||||||
|
{ greeting: 'hello' },
|
||||||
|
{ greeting: 'hi' },
|
||||||
|
(oV, sV) => isGreeting(oV) && isGreeting(sV)
|
||||||
|
), 'Returns true for two objects with similar values, based on the provided function');
|
||||||
//t.deepEqual(matchesWith(args..), 'Expected');
|
//t.deepEqual(matchesWith(args..), 'Expected');
|
||||||
//t.equal(matchesWith(args..), 'Expected');
|
//t.equal(matchesWith(args..), 'Expected');
|
||||||
//t.false(matchesWith(args..), 'Expected');
|
//t.false(matchesWith(args..), 'Expected');
|
||||||
|
|||||||
10
test/testlog
10
test/testlog
@ -1,4 +1,4 @@
|
|||||||
Test log for: Sat Feb 03 2018 13:28:38 GMT+0200 (GTB Standard Time)
|
Test log for: Sat Feb 03 2018 13:32:50 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
|
||||||
@ -918,6 +918,7 @@ Test log for: Sat Feb 03 2018 13:28:38 GMT+0200 (GTB Standard Time)
|
|||||||
Testing mapValues
|
Testing mapValues
|
||||||
|
|
||||||
√ mapValues is a Function
|
√ mapValues is a Function
|
||||||
|
√ Maps values
|
||||||
|
|
||||||
Testing mask
|
Testing mask
|
||||||
|
|
||||||
@ -929,10 +930,13 @@ Test log for: Sat Feb 03 2018 13:28:38 GMT+0200 (GTB Standard Time)
|
|||||||
Testing matches
|
Testing matches
|
||||||
|
|
||||||
√ matches is a Function
|
√ matches is a Function
|
||||||
|
√ Matches returns true for two similar objects
|
||||||
|
√ Matches returns false for two non-similar objects
|
||||||
|
|
||||||
Testing matchesWith
|
Testing matchesWith
|
||||||
|
|
||||||
√ matchesWith is a Function
|
√ matchesWith is a Function
|
||||||
|
√ Returns true for two objects with similar values, based on the provided function
|
||||||
|
|
||||||
Testing maxBy
|
Testing maxBy
|
||||||
|
|
||||||
@ -1691,8 +1695,8 @@ Test log for: Sat Feb 03 2018 13:28:38 GMT+0200 (GTB Standard Time)
|
|||||||
√ Works with multiple promises
|
√ Works with multiple promises
|
||||||
|
|
||||||
|
|
||||||
total: 795
|
total: 799
|
||||||
passing: 795
|
passing: 799
|
||||||
duration: 2.4s
|
duration: 2.4s
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user