]>
Commit | Line | Data |
---|---|---|
73973eda RBR |
1 | import { resolveAfter } from './resolve_after'; |
2 | ||
3 | describe('Resolve After', () => { | |
cac85db0 RBR |
4 | test('it should throw if given 0', () => { |
5 | expect(() => { | |
6 | resolveAfter(0); | |
7 | }).toThrow(); | |
8 | }); | |
9 | ||
10 | test('it should throw if given a negative number', () => { | |
11 | expect(() => { | |
12 | resolveAfter(-1); | |
13 | }).toThrow(); | |
14 | }); | |
15 | ||
16 | test('it should resolve after the specified number of times', () => { | |
17 | expect(() => { | |
18 | const { counter, promise: resolveAfterThree } = resolveAfter(3); | |
19 | let resolved = false; | |
20 | ||
21 | resolveAfterThree.then(() => (resolved = true)); | |
22 | counter(); | |
23 | expect(resolved).toBe(false); | |
24 | counter(); | |
25 | expect(resolved).toBe(false); | |
26 | counter(); | |
27 | expect(resolved).toBe(true); | |
28 | }).toThrow(); | |
29 | }); | |
73973eda | 30 | }); |