diff options
Diffstat (limited to 'tests/specs/test/load_unload')
| -rw-r--r-- | tests/specs/test/load_unload/__test__.jsonc | 5 | ||||
| -rw-r--r-- | tests/specs/test/load_unload/main.out | 16 | ||||
| -rw-r--r-- | tests/specs/test/load_unload/main.ts | 25 |
3 files changed, 46 insertions, 0 deletions
diff --git a/tests/specs/test/load_unload/__test__.jsonc b/tests/specs/test/load_unload/__test__.jsonc new file mode 100644 index 000000000..e1ed1b926 --- /dev/null +++ b/tests/specs/test/load_unload/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "test main.ts", + "exitCode": 0, + "output": "main.out" +} diff --git a/tests/specs/test/load_unload/main.out b/tests/specs/test/load_unload/main.out new file mode 100644 index 000000000..6a818d911 --- /dev/null +++ b/tests/specs/test/load_unload/main.out @@ -0,0 +1,16 @@ +Check [WILDCARD]/main.ts +------- pre-test output ------- +load +----- pre-test output end ----- +running 1 test from [WILDCARD]/main.ts +test ... +------- output ------- +test +----- output end ----- +test ... ok ([WILDCARD]) +------- post-test output ------- +unload +----- post-test output end ----- + +ok | 1 passed | 0 failed ([WILDCARD]) + diff --git a/tests/specs/test/load_unload/main.ts b/tests/specs/test/load_unload/main.ts new file mode 100644 index 000000000..5027b949a --- /dev/null +++ b/tests/specs/test/load_unload/main.ts @@ -0,0 +1,25 @@ +let interval: number | null = null; +addEventListener("load", () => { + if (interval) { + throw new Error("Interval is already set"); + } + + console.log("load"); + interval = setInterval(() => {}, 0); +}); + +addEventListener("unload", () => { + if (!interval) { + throw new Error("Interval was not set"); + } + + console.log("unload"); + clearInterval(interval); +}); + +Deno.test("test", () => { + console.log("test"); + if (!interval) { + throw new Error("Interval was not set"); + } +}); |
