]>
Commit | Line | Data |
---|---|---|
1 | import { resolveAfter } from './resolve_after'; | |
2 | ||
3 | describe('Resolve After', () => { | |
4 | ||
5 | test('it should throw if given 0', () => { | |
6 | ||
7 | expect(() => { | |
8 | ||
9 | resolveAfter(0); | |
10 | }).toThrow(); | |
11 | }); | |
12 | ||
13 | test('it should throw if given a negative number', () => { | |
14 | ||
15 | expect(() => { | |
16 | ||
17 | resolveAfter(-1); | |
18 | }).toThrow(); | |
19 | }); | |
20 | ||
21 | test('it should throw if given a negative number', () => { | |
22 | ||
23 | expect(() => { | |
24 | ||
25 | resolveAfter('lol'); | |
26 | }).toThrow(); | |
27 | }); | |
28 | ||
29 | test('it should resolve after the specified number of times', () => { | |
30 | ||
31 | expect(() => { | |
32 | ||
33 | const { counter, resolveAfterThree } = resolveAfter(3); | |
34 | let resolved = false; | |
35 | ||
36 | resolveAfterThree.then(() => (resolved = true)); | |
37 | counter(); | |
38 | expect(resolved).toBe(false); | |
39 | counter(); | |
40 | expect(resolved).toBe(false); | |
41 | counter(); | |
42 | expect(resolved).toBe(true); | |
43 | }).toThrow(); | |
44 | }); | |
45 | }); |