aboutsummaryrefslogtreecommitdiff
path: root/src/utils/resolve_after.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/resolve_after.test.js')
-rw-r--r--src/utils/resolve_after.test.js45
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();
+ });
+});