Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should not duplicate the first item if it is the one that changed', () => {
expect(
onChildChanged([val1, val2, val3], val1, toKey, null!)
).not.toEqual([val1, val1, val2, val3]);
});
it('should move the child after the specified prevKey', () => {
expect(onChildChanged([val1, val2], val1, toKey, 'key2')).toEqual([val2, val1]);
});
it('should move the child to the beginning if prevKey is null', () => {
expect(
onChildChanged([val1, val2, val3], val2, toKey, null!)
).toEqual([val2, val1, val3]);
});
it('should not mutate the input array', () => {
let inputArr = [val1, val2];
expect(onChildChanged(inputArr, val1, toKey, 'key2')).not.toEqual(inputArr);
});