Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
6
test/symmetricDifferenceBy/symmetricDifferenceBy.js
Normal file
6
test/symmetricDifferenceBy/symmetricDifferenceBy.js
Normal file
@ -0,0 +1,6 @@
|
||||
const symmetricDifferenceBy = (a, b, fn) => {
|
||||
const sA = new Set(a.map(v => fn(v))),
|
||||
sB = new Set(b.map(v => fn(v)));
|
||||
return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))];
|
||||
};
|
||||
module.exports = symmetricDifferenceBy;
|
||||
10
test/symmetricDifferenceBy/symmetricDifferenceBy.test.js
Normal file
10
test/symmetricDifferenceBy/symmetricDifferenceBy.test.js
Normal file
@ -0,0 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const symmetricDifferenceBy = require('./symmetricDifferenceBy.js');
|
||||
|
||||
|
||||
test('symmetricDifferenceBy is a Function', () => {
|
||||
expect(symmetricDifferenceBy).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor), [ 1.2, 3.4 ], 'Returns the symmetric difference between two arrays, after applying the provided function to each array element of both');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user