removeAtArrayIndex.spec.tsx 663 B

123456789101112131415161718192021
  1. import {removeAtArrayIndex} from 'sentry/utils/removeAtArrayIndex';
  2. describe('utils/removeAtArrayIndex', function () {
  3. it('removes simple value at index', function () {
  4. const arr = [1, 2, 3];
  5. expect(removeAtArrayIndex(arr, 1)).toEqual([1, 3]);
  6. });
  7. it('does not mutate array', function () {
  8. const arr = [1, 2, 3];
  9. expect(removeAtArrayIndex(arr, 0)).toEqual([2, 3]);
  10. expect(arr).toEqual([1, 2, 3]);
  11. });
  12. it('removes at boundaries of array', function () {
  13. const arr = [1, 2, 3];
  14. expect(removeAtArrayIndex(arr, 0)).toEqual([2, 3]);
  15. const arr2 = [1, 2, 3];
  16. expect(removeAtArrayIndex(arr2, 2)).toEqual([1, 2]);
  17. });
  18. });