fleet/frontend/utilities/replace_array_item/replace_array_item.tests.js
Zach Wasserman 0670db66c4
Migrate JS tests to Jest and update libraries (#74)
- Move from Mocha to Jest for JS testing (Jest seems to have better support for
 'watching' tests and a more active community these days).
- Codemod existing tests to Jest syntax (using https://github.com/skovhus/jest-codemods)
- Fix some errors in tests that were previously hidden.
- Update Babel.
2020-12-01 10:15:12 -08:00

18 lines
763 B
JavaScript

import replaceArrayItem from 'utilities/replace_array_item';
describe('replaceArrayItem - utility', () => {
it('substitutes the item in the array with its replacement', () => {
const groob = { id: 23, name: 'Groob' };
const jason = { id: 78, name: 'Jason' };
const john = { id: 78, name: 'John' };
const zach = { id: 78, name: 'Zach' };
const mike = { id: 78, name: 'Mike' };
const arr1 = [101, 102, 2, 104];
const arr2 = [groob, jason, john];
expect(replaceArrayItem(arr1, 2, 'hi')).toEqual([101, 102, 'hi', 104]);
expect(replaceArrayItem(arr1, 103, 'hi')).toEqual(arr1);
expect(replaceArrayItem(arr2, jason, zach)).toEqual([groob, zach, john]);
expect(replaceArrayItem(arr2, mike, zach)).toEqual(arr2);
});
});