mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
24 lines
706 B
TypeScript
24 lines
706 B
TypeScript
import {replaceAtArrayIndex} from 'sentry/utils/replaceAtArrayIndex';
|
|
|
|
describe('utils/replaceAtArrayIndex', function () {
|
|
it('replaces simple value at index', function () {
|
|
const arr = [1, 2, 3];
|
|
|
|
expect(replaceAtArrayIndex(arr, 1, 40)).toEqual([1, 40, 3]);
|
|
});
|
|
|
|
it('does not mutate array', function () {
|
|
const arr = [1, 2, 3];
|
|
expect(replaceAtArrayIndex(arr, 0, 40)).toEqual([40, 2, 3]);
|
|
expect(arr).toEqual([1, 2, 3]);
|
|
});
|
|
|
|
it('replaces at boundaries of array', function () {
|
|
const arr = [1, 2, 3];
|
|
expect(replaceAtArrayIndex(arr, 0, 40)).toEqual([40, 2, 3]);
|
|
|
|
const arr2 = [1, 2, 3];
|
|
expect(replaceAtArrayIndex(arr2, 2, 40)).toEqual([1, 2, 40]);
|
|
});
|
|
});
|