Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
6
test/indexOfAll/indexOfAll.js
Normal file
6
test/indexOfAll/indexOfAll.js
Normal file
@ -0,0 +1,6 @@
|
||||
const indexOfAll = (arr, val) => {
|
||||
const indices = [];
|
||||
arr.forEach((el, i) => el === val && indices.push(i));
|
||||
return indices;
|
||||
};
|
||||
module.exports = indexOfAll;
|
||||
10
test/indexOfAll/indexOfAll.test.js
Normal file
10
test/indexOfAll/indexOfAll.test.js
Normal file
@ -0,0 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const indexOfAll = require('./indexOfAll.js');
|
||||
|
||||
|
||||
test('indexOfAll is a Function', () => {
|
||||
expect(indexOfAll).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(indexOfAll([1, 2, 3, 1, 2, 3], 1), [0,3], "Returns all indices of val in an array");
|
||||
t.deepEqual(indexOfAll([1, 2, 3], 4), [], "Returns all indices of val in an array");
|
||||
|
||||
Reference in New Issue
Block a user