Files
sentinel/static/app/utils/removeAtArrayIndex.spec.tsx
2024-02-15 17:01:50 +00:00

22 lines
663 B
TypeScript

import {removeAtArrayIndex} from 'sentry/utils/removeAtArrayIndex';
describe('utils/removeAtArrayIndex', function () {
it('removes simple value at index', function () {
const arr = [1, 2, 3];
expect(removeAtArrayIndex(arr, 1)).toEqual([1, 3]);
});
it('does not mutate array', function () {
const arr = [1, 2, 3];
expect(removeAtArrayIndex(arr, 0)).toEqual([2, 3]);
expect(arr).toEqual([1, 2, 3]);
});
it('removes at boundaries of array', function () {
const arr = [1, 2, 3];
expect(removeAtArrayIndex(arr, 0)).toEqual([2, 3]);
const arr2 = [1, 2, 3];
expect(removeAtArrayIndex(arr2, 2)).toEqual([1, 2]);
});
});