diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/test_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/test/load_unload.out | 6 | ||||
-rw-r--r-- | cli/tests/testdata/test/load_unload.ts | 22 |
3 files changed, 34 insertions, 0 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 36bd6b94c..355a3c261 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -49,6 +49,12 @@ itest!(fail { output: "test/fail.out", }); +itest!(load_unload { + args: "test test/load_unload.ts", + exit_code: 0, + output: "test/load_unload.out", +}); + itest!(doc { args: "test --doc --allow-all test/doc.ts", exit_code: 1, diff --git a/cli/tests/testdata/test/load_unload.out b/cli/tests/testdata/test/load_unload.out new file mode 100644 index 000000000..b407ce122 --- /dev/null +++ b/cli/tests/testdata/test/load_unload.out @@ -0,0 +1,6 @@ +Check [WILDCARD]/test/load_unload.ts +running 1 test from [WILDCARD]/test/load_unload.ts +test test ... ok ([WILDCARD]) + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/testdata/test/load_unload.ts b/cli/tests/testdata/test/load_unload.ts new file mode 100644 index 000000000..2bd04a676 --- /dev/null +++ b/cli/tests/testdata/test/load_unload.ts @@ -0,0 +1,22 @@ +let interval: number | null = null; +addEventListener("load", () => { + if (interval) { + throw new Error("Interval is already set"); + } + + interval = setInterval(() => {}, 0); +}); + +addEventListener("unload", () => { + if (!interval) { + throw new Error("Interval was not set"); + } + + clearInterval(interval); +}); + +Deno.test("test", () => { + if (!interval) { + throw new Error("Interval was not set"); + } +}); |