diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-05-02 00:23:16 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-05-02 00:23:16 +0200 |
| commit | 73973edab9aaa81312ba80a68bfe34bf5abcecd9 (patch) | |
| tree | 9d3916655c416407e12dc66e9f1f865cec0fb2b3 /src/utils/resolve_after.test.js | |
| parent | 55fb920baa9792266be1a6b981f954c622c1eaf9 (diff) | |
Add pact test for forums store
Diffstat (limited to 'src/utils/resolve_after.test.js')
| -rw-r--r-- | src/utils/resolve_after.test.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/utils/resolve_after.test.js b/src/utils/resolve_after.test.js new file mode 100644 index 0000000..f7fc753 --- /dev/null +++ b/src/utils/resolve_after.test.js @@ -0,0 +1,45 @@ +import { resolveAfter } from './resolve_after'; + +describe('Resolve After', () => { + + test('it should throw if given 0', () => { + + expect(() => { + + resolveAfter(0); + }).toThrow(); + }); + + test('it should throw if given a negative number', () => { + + expect(() => { + + resolveAfter(-1); + }).toThrow(); + }); + + test('it should throw if given a negative number', () => { + + expect(() => { + + resolveAfter('lol'); + }).toThrow(); + }); + + test('it should resolve after the specified number of times', () => { + + expect(() => { + + const { counter, resolveAfterThree } = resolveAfter(3); + let resolved = false; + + resolveAfterThree.then(() => (resolved = true)); + counter(); + expect(resolved).toBe(false); + counter(); + expect(resolved).toBe(false); + counter(); + expect(resolved).toBe(true); + }).toThrow(); + }); +}); |