diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2021-06-25 10:44:14 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 03:44:14 +0200 |
commit | 66c5f41c5bd5fa08daa09f8650135000c1787829 (patch) | |
tree | 05ad5900822d01316ad0c193cd7fcc7953bdf32c /cli/tests/unit/signal_test.ts | |
parent | dd4ed825762d32ca9f791bda3bb9c459886c7061 (diff) |
test(cli): refactor the usages of delay (#11098)
This PR refactors the usages of delay utility in js unit testing. The same
utiliy is defined in several places with different names. This PR replaces those
usages with the one provided in std/async/delay.ts to improve the readability
and consistency of test code.
Diffstat (limited to 'cli/tests/unit/signal_test.ts')
-rw-r--r-- | cli/tests/unit/signal_test.ts | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/cli/tests/unit/signal_test.ts b/cli/tests/unit/signal_test.ts index e0e94b49a..9deca0837 100644 --- a/cli/tests/unit/signal_test.ts +++ b/cli/tests/unit/signal_test.ts @@ -4,15 +4,10 @@ import { assertEquals, assertThrows, deferred, + delay, unitTest, } from "./test_util.ts"; -function defer(n: number): Promise<void> { - return new Promise((resolve: () => void, _) => { - setTimeout(resolve, n); - }); -} - unitTest( { ignore: Deno.build.os !== "windows" }, function signalsNotImplemented(): void { @@ -113,11 +108,11 @@ unitTest( let c = 0; const sig = Deno.signal(Deno.Signal.SIGUSR1); setTimeout(async () => { - await defer(20); + await delay(20); for (const _ of Array(3)) { // Sends SIGUSR1 3 times. Deno.kill(Deno.pid, Deno.Signal.SIGUSR1); - await defer(20); + await delay(20); } sig.dispose(); resolvable.resolve(); |