1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

remove unnecessary delay in std/signal tests (#4703)

This commit is contained in:
Chris Knight 2020-04-11 03:03:41 +01:00 committed by GitHub
parent 2af9f5f2cf
commit 3e51e67f8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,8 +3,10 @@ import { assertEquals, assertThrows } from "../testing/asserts.ts";
import { delay } from "../util/async.ts"; import { delay } from "../util/async.ts";
import { signal, onSignal } from "./mod.ts"; import { signal, onSignal } from "./mod.ts";
if (Deno.build.os !== "win") { test({
test("signal() throws when called with empty signals", (): void => { name: "signal() throws when called with empty signals",
ignore: Deno.build.os === "win",
fn() {
assertThrows( assertThrows(
() => { () => {
// @ts-ignore // @ts-ignore
@ -13,10 +15,12 @@ if (Deno.build.os !== "win") {
Error, Error,
"No signals are given. You need to specify at least one signal to create a signal stream." "No signals are given. You need to specify at least one signal to create a signal stream."
); );
}); },
});
test({ test({
name: "signal() iterates for multiple signals", name: "signal() iterates for multiple signals",
ignore: Deno.build.os === "win",
fn: async (): Promise<void> => { fn: async (): Promise<void> => {
// This prevents the program from exiting. // This prevents the program from exiting.
const t = setInterval(() => {}, 1000); const t = setInterval(() => {}, 1000);
@ -52,15 +56,12 @@ if (Deno.build.os !== "win") {
assertEquals(c, 6); assertEquals(c, 6);
clearTimeout(t); clearTimeout(t);
// Clear timeout clears interval, but interval promise is not
// yet resolved, delay to next turn of event loop otherwise,
// we'll be leaking resources.
await delay(10);
}, },
}); });
test({ test({
name: "onSignal() registers and disposes of event handler", name: "onSignal() registers and disposes of event handler",
ignore: Deno.build.os === "win",
async fn() { async fn() {
// This prevents the program from exiting. // This prevents the program from exiting.
const t = setInterval(() => {}, 1000); const t = setInterval(() => {}, 1000);
@ -86,10 +87,5 @@ if (Deno.build.os !== "win") {
assertEquals(calledCount, 2); assertEquals(calledCount, 2);
clearTimeout(t); clearTimeout(t);
// Clear timeout clears interval, but interval promise is not
// yet resolved, delay to next turn of event loop otherwise,
// we'll be leaking resources.
await delay(10);
}, },
}); });
}