Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
9
test/partition/partition.js
Normal file
9
test/partition/partition.js
Normal file
@ -0,0 +1,9 @@
|
||||
const partition = (arr, fn) =>
|
||||
arr.reduce(
|
||||
(acc, val, i, arr) => {
|
||||
acc[fn(val, i, arr) ? 0 : 1].push(val);
|
||||
return acc;
|
||||
},
|
||||
[[], []]
|
||||
);
|
||||
module.exports = partition;
|
||||
10
test/partition/partition.test.js
Normal file
10
test/partition/partition.test.js
Normal file
@ -0,0 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const partition = require('./partition.js');
|
||||
|
||||
|
||||
test('partition is a Function', () => {
|
||||
expect(partition).toBeInstanceOf(Function);
|
||||
});
|
||||
const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
|
||||
t.deepEqual(partition(users, o => o.active), [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]], "Groups the elements into two arrays, depending on the provided function's truthiness for each element.");
|
||||
|
||||
Reference in New Issue
Block a user