-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.test.js
53 lines (40 loc) · 1.46 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { List } from './index.js'
describe('List', () => {
it('should create list', () => {
const list = List({ initial: [1, 2, 3, 4], initialOrder: true })
const expected = [1, 2, 3, 4];
const actual = list.items
expect(actual).toEqual(expected)
})
it('should sort initial list items', () => {
const list = List({ initial: [4, 3, -1, 1, 2, 5, 0] })
const expected = [-1, 0, 1, 2, 3, 4, 5];
const actual = list.items
expect(actual).toEqual(expected)
})
it('should sort initial list items', () => {
const list = List({ initial: [100, -100, 10, 9, 200, -300] })
const expected = [-300, -100, 9, 10, 100, 200];
const actual = list.items
expect(actual).toEqual(expected)
})
it('should insert b into list a', () => {
const list = List({ initial: [1, 2, 3, 4], initialOrder: true })
const expected = [1, 2, 3, 4, 5];
const actual = list.insert(5).items
expect(actual).toEqual(expected)
})
it('should remove b from list a', () => {
const list = List({ initial: [1, 2, 3, 4], initialOrder: true })
const expected = [1, 2, 3];
const actual = list.remove(4).items
expect(actual).toEqual(expected)
})
it('should findIndex of b at list a', () => {
const list = List({ initial: [1, 2, 3, 4], initialOrder: true })
const expected = 2;
const actual = list.findIndex(3)
expect(actual).toEqual(expected)
})
// PLEASE cover the rest of the methods/scenarios with tests
})