mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 14:11:14 +00:00
test(ext/node): add timers_tests.ts from std/node (#18472)
This commit is contained in:
parent
04399d138e
commit
bacbf94925
1 changed files with 52 additions and 0 deletions
52
cli/tests/unit_node/timers_test.ts
Normal file
52
cli/tests/unit_node/timers_test.ts
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { assert } from "../../../test_util/std/testing/asserts.ts";
|
||||||
|
import * as timers from "node:timers";
|
||||||
|
import * as timersPromises from "node:timers/promises";
|
||||||
|
|
||||||
|
Deno.test("[node/timers setTimeout]", () => {
|
||||||
|
{
|
||||||
|
const { clearTimeout, setTimeout } = timers;
|
||||||
|
const id = setTimeout(() => {});
|
||||||
|
clearTimeout(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const id = timers.setTimeout(() => {});
|
||||||
|
timers.clearTimeout(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("[node/timers setInterval]", () => {
|
||||||
|
{
|
||||||
|
const { clearInterval, setInterval } = timers;
|
||||||
|
const id = setInterval(() => {});
|
||||||
|
clearInterval(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const id = timers.setInterval(() => {});
|
||||||
|
timers.clearInterval(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("[node/timers setImmediate]", () => {
|
||||||
|
{
|
||||||
|
const { clearImmediate, setImmediate } = timers;
|
||||||
|
const id = setImmediate(() => {});
|
||||||
|
clearImmediate(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const id = timers.setImmediate(() => {});
|
||||||
|
timers.clearImmediate(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("[node/timers/promises setTimeout]", () => {
|
||||||
|
const { setTimeout } = timersPromises;
|
||||||
|
const p = setTimeout(0);
|
||||||
|
|
||||||
|
assert(p instanceof Promise);
|
||||||
|
return p;
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue