1 | import test from "ava";
|
2 | import * as sinon from "sinon";
|
3 | import Queue from "../src/queue";
|
4 |
|
5 | test.serial("test for class Queue", async (t) => {
|
6 | const q = new Queue();
|
7 |
|
8 | t.is(null, q.next());
|
9 | t.is(0, q.getLength());
|
10 |
|
11 | const [ v1, v2, v3, v4, v5] = [ 1, 2, 3, 4, 5 ].map((v) => ({
|
12 | planName: "test",
|
13 | uid: `uid${v}`,
|
14 | url: `url${v}`,
|
15 | }));
|
16 |
|
17 | q.add(v2);
|
18 | q.add(v3);
|
19 | q.jump(v1);
|
20 | q.add(v4);
|
21 |
|
22 | t.is(4, q.getLength());
|
23 | t.is(v1, q.next());
|
24 | t.is(v2, q.next());
|
25 | t.is(v3, q.next());
|
26 | t.is(1, q.getLength());
|
27 |
|
28 | q.add(v5);
|
29 |
|
30 | t.is(v4, q.next());
|
31 | t.is(v5, q.next());
|
32 | t.is(null, q.next());
|
33 | });
|