Files
directus/packages/shared/src/utils/move-in-array.test.ts
Jay Cammarano e7b4153028 Tests for listFolders, resolvePackage (#8356)
* listFolders test passing 100% coverage

* added tmp package

* listFolders test updated to use random temp folder

* add package tmp to workspace

* tmp as dev dependency

* direct imports

* resolve-packages passing 100% coverage

* fixed tmpdir location in list-folders

* Pin tmp

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-09-28 19:10:08 -04:00

21 lines
708 B
TypeScript

import { moveInArray } from './move-in-array';
describe('moveInArray', () => {
const testArray = [1, 2, 3, 4, 5, 6];
it('returns the original array if the item is undefined', () => {
expect(moveInArray(testArray, 6, 2)).toStrictEqual(testArray);
});
it('moves the item to the right to the specified index', () => {
expect(moveInArray(testArray, 1, 2)).toStrictEqual([1, 3, 2, 4, 5, 6]);
});
it('moves the item to the left to the specified index', () => {
expect(moveInArray(testArray, 5, -3)).toStrictEqual([1, 2, 3, 6, 4, 5]);
});
it('returns the original array when passed the same toIndex and fromIndex', () => {
expect(moveInArray(testArray, 0, 0)).toStrictEqual(testArray);
});
});