Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
8
test/matchesWith/matchesWith.js
Normal file
8
test/matchesWith/matchesWith.js
Normal file
@ -0,0 +1,8 @@
|
||||
const matchesWith = (obj, source, fn) =>
|
||||
Object.keys(source).every(
|
||||
key =>
|
||||
obj.hasOwnProperty(key) && fn
|
||||
? fn(obj[key], source[key], key, obj, source)
|
||||
: obj[key] == source[key]
|
||||
);
|
||||
module.exports = matchesWith;
|
||||
15
test/matchesWith/matchesWith.test.js
Normal file
15
test/matchesWith/matchesWith.test.js
Normal file
@ -0,0 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const matchesWith = require('./matchesWith.js');
|
||||
|
||||
|
||||
test('matchesWith is a Function', () => {
|
||||
expect(matchesWith).toBeInstanceOf(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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user