Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
9
test/pullAtValue/pullAtValue.js
Normal file
9
test/pullAtValue/pullAtValue.js
Normal file
@ -0,0 +1,9 @@
|
||||
const pullAtValue = (arr, pullArr) => {
|
||||
let removed = [],
|
||||
pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)),
|
||||
mutateTo = arr.filter((v, i) => !pullArr.includes(v));
|
||||
arr.length = 0;
|
||||
mutateTo.forEach(v => arr.push(v));
|
||||
return removed;
|
||||
};
|
||||
module.exports = pullAtValue;
|
||||
13
test/pullAtValue/pullAtValue.test.js
Normal file
13
test/pullAtValue/pullAtValue.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const expect = require('expect');
|
||||
const pullAtValue = require('./pullAtValue.js');
|
||||
|
||||
|
||||
test('pullAtValue is a Function', () => {
|
||||
expect(pullAtValue).toBeInstanceOf(Function);
|
||||
});
|
||||
let myArray = ['a', 'b', 'c', 'd'];
|
||||
let pulled = pullAtValue(myArray, ['b', 'd']);
|
||||
t.deepEqual(myArray, [ 'a', 'c' ], 'Pulls the specified values');
|
||||
t.deepEqual(pulled, [ 'b', 'd' ], 'Pulls the specified values');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user