-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
_inspect_test.ts
54 lines (53 loc) · 1.86 KB
/
_inspect_test.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { assertSnapshot } from "@std/testing/snapshot";
import { inspect } from "./_inspect.ts";
Deno.test("inspect", async (t) => {
await t.step("string", async (t) => {
await assertSnapshot(t, inspect("hello world"));
});
await t.step("number", async (t) => {
await assertSnapshot(t, inspect(100));
});
await t.step("bigint", async (t) => {
await assertSnapshot(t, inspect(100n));
});
await t.step("boolean", async (t) => {
await assertSnapshot(t, inspect(true));
});
await t.step("array", async (t) => {
await assertSnapshot(t, inspect([]));
await assertSnapshot(t, inspect([0, 1, 2]));
await assertSnapshot(t, inspect([0, "a", true]));
await assertSnapshot(t, inspect([0, [1, [2]]]));
});
await t.step("record", async (t) => {
await assertSnapshot(t, inspect({}));
await assertSnapshot(t, inspect({ a: 0, b: 1, c: 2 }));
await assertSnapshot(t, inspect({ a: "a", b: 1, c: true }));
await assertSnapshot(t, inspect({ a: { b: { c: 0 } } }));
await assertSnapshot(t, inspect({ [Symbol("a")]: 0 }));
await assertSnapshot(t, inspect({ a: 0, [Symbol("b")]: 1, c: true }));
await assertSnapshot(
t,
inspect({ [Symbol("a")]: { [Symbol("b")]: { [Symbol("c")]: 0 } } }),
);
});
await t.step("function", async (t) => {
await assertSnapshot(t, inspect(inspect));
await assertSnapshot(t, inspect(() => {}));
});
await t.step("null", async (t) => {
await assertSnapshot(t, inspect(null));
});
await t.step("undefined", async (t) => {
await assertSnapshot(t, inspect(undefined));
});
await t.step("symbol", async (t) => {
await assertSnapshot(t, inspect(Symbol("a")));
});
await t.step("date", async (t) => {
await assertSnapshot(t, inspect(new Date()));
});
await t.step("promise", async (t) => {
await assertSnapshot(t, inspect(new Promise(() => {})));
});
});