-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtest.js
20 lines (17 loc) · 768 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import test from 'ava';
import {arrayMoveImmutable, arrayMoveMutable} from './index.js';
const fixture = [1, 2, 3, 4, 5];
test('arrayMoveImmutable()', t => {
t.deepEqual(arrayMoveImmutable(fixture, 3, 0), [4, 1, 2, 3, 5]);
t.deepEqual(arrayMoveImmutable(fixture, -1, 0), [5, 1, 2, 3, 4]);
t.deepEqual(arrayMoveImmutable(fixture, 1, -2), [1, 3, 4, 2, 5]);
t.deepEqual(arrayMoveImmutable(fixture, -3, -4), [1, 3, 2, 4, 5]);
t.deepEqual(arrayMoveImmutable(fixture, 5, 6), [1, 2, 3, 4, 5]);
t.deepEqual(arrayMoveImmutable(fixture, -1000, 0), fixture);
t.deepEqual(arrayMoveImmutable(fixture, 1000, 0), fixture);
});
test('arrayMoveMutable()', t => {
const fixture2 = [...fixture];
arrayMoveMutable(fixture2, 3, 0);
t.deepEqual(fixture2, [4, 1, 2, 3, 5]);
});