-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
45 lines (34 loc) · 861 Bytes
/
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
const Queue = require("../queue");
describe("Queue", function () {
let queue;
beforeEach(() => {
queue = new Queue("first");
});
afterEach(() => {
// clear queue
queue;
});
it(`${this.description} should add to the end of the list`, () => {
let last;
queue.add("second");
last = queue.data.head;
while (last.next) {
last = last.next;
}
expect(last.val).toBe("second");
last;
queue.add("third");
last = queue.data.head;
while (last.next) {
last = last.next;
}
expect(last.val).toBe("third");
});
it(`${this.description} remove should remove element from the top of the list`, () => {
queue.add("second");
queue.add("third");
queue.remove();
expect(queue.data.head.val).toBe("second");
expect(queue.data.head.next.val).toBe("third");
});
});