Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
5
test/takeWhile/takeWhile.js
Normal file
5
test/takeWhile/takeWhile.js
Normal file
@ -0,0 +1,5 @@
|
||||
const takeWhile = (arr, func) => {
|
||||
for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i);
|
||||
return arr;
|
||||
};
|
||||
module.exports = takeWhile;
|
||||
10
test/takeWhile/takeWhile.test.js
Normal file
10
test/takeWhile/takeWhile.test.js
Normal file
@ -0,0 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const takeWhile = require('./takeWhile.js');
|
||||
|
||||
|
||||
test('takeWhile is a Function', () => {
|
||||
expect(takeWhile).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(takeWhile([1, 2, 3, 4], n => n >= 3), [1, 2], 'Removes elements until the function returns true');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user