forked from MathisBullinger/froebel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisPromise.test.ts
More file actions
27 lines (23 loc) · 771 Bytes
/
Copy pathisPromise.test.ts
File metadata and controls
27 lines (23 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import isPromise, { isNotPromise } from "./isPromise.ts";
import { assertEquals, assertNotEquals } from "testing/asserts.ts";
Deno.test("is promise", () => {
const prom = new Promise(() => {});
assertEquals(isPromise(2), false);
assertEquals(isPromise(""), false);
assertEquals(isPromise(null), false);
assertEquals(isPromise({}), false);
assertEquals(
isPromise(() => {}),
false,
);
assertEquals(
isPromise(async () => {}),
false,
);
assertEquals(isPromise({ then: "" }), false);
assertEquals(isPromise(prom), true);
assertEquals(isPromise((async () => {})()), true);
assertEquals(isPromise({ then() {} }), true);
assertNotEquals(isPromise(1), isNotPromise(1));
assertNotEquals(isPromise(prom), isNotPromise(prom));
});