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

timers: align unit tests with others

This commit is contained in:
Li Hao 2018-10-08 14:58:44 +08:00 committed by Ryan Dahl
parent 900dd6fa42
commit 951e5def98

View file

@ -32,25 +32,21 @@ test(async function timeoutSuccess() {
}); });
test(async function timeoutArgs() { test(async function timeoutArgs() {
const { promise, resolve } = deferred();
const arg = 1; const arg = 1;
await new Promise((resolve, reject) => { setTimeout(
setTimeout( (a, b, c) => {
(a, b, c) => { assertEqual(a, arg);
try { assertEqual(b, arg.toString());
assertEqual(a, arg); assertEqual(c, [arg]);
assertEqual(b, arg.toString()); resolve();
assertEqual(c, [arg]); },
resolve(); 10,
} catch (e) { arg,
reject(e); arg.toString(),
} [arg]
}, );
10, await promise;
arg,
arg.toString(),
[arg]
);
});
}); });
test(async function timeoutCancelSuccess() { test(async function timeoutCancelSuccess() {
@ -151,16 +147,8 @@ test(async function intervalOrdering() {
clearTimeout(timers[i]); clearTimeout(timers[i]);
} }
} }
await new Promise((resolve, reject) => { await waitForMs(100);
setTimeout(() => { assertEqual(timeouts, 1);
try {
assertEqual(timeouts, 1);
resolve();
} catch (e) {
reject(e);
}
}, 100);
});
}); });
test(async function intervalCancelInvalidSilentFail() { test(async function intervalCancelInvalidSilentFail() {