summaryrefslogtreecommitdiff
path: root/tests/unit_node/timers_test.ts
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-03-08 15:58:43 -0800
committerGitHub <noreply@github.com>2024-03-08 15:58:43 -0800
commit529f79505d5924ee461593840c9383c5d8f6ed65 (patch)
treeec39563aad53fd1e0dfc4b7eea18aa5c6e9acf64 /tests/unit_node/timers_test.ts
parent58c28d9879c79c3d6cf9568ce4ee141bdd9ca59c (diff)
fix(ext/node): Add Immediate class to mirror NodeJS.Immediate (#22808)
Fixes #21660 Adds a basic `Immediate` class to mirror `NodeJS.Immediate`, and changes `setImmediate` and `clearImmediate` to return and accept (respectively) `Immediate` objects. Note that for now {ref,unref,hasRef} are effectively stubs, as deno_core doesn't really natively support immediates (they're currently modeled as timers with delay of 0). Eventually we probably want to actually implement these properly.
Diffstat (limited to 'tests/unit_node/timers_test.ts')
-rw-r--r--tests/unit_node/timers_test.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/unit_node/timers_test.ts b/tests/unit_node/timers_test.ts
index 9ce015d23..c0b49c998 100644
--- a/tests/unit_node/timers_test.ts
+++ b/tests/unit_node/timers_test.ts
@@ -33,13 +33,13 @@ Deno.test("[node/timers setInterval]", () => {
Deno.test("[node/timers setImmediate]", () => {
{
const { clearImmediate, setImmediate } = timers;
- const id = setImmediate(() => {});
- clearImmediate(id);
+ const imm = setImmediate(() => {});
+ clearImmediate(imm);
}
{
- const id = timers.setImmediate(() => {});
- timers.clearImmediate(id);
+ const imm = timers.setImmediate(() => {});
+ timers.clearImmediate(imm);
}
});
@@ -60,3 +60,13 @@ Deno.test("[node/timers refresh cancelled timer]", () => {
clearTimeout(p);
p.refresh();
});
+
+Deno.test("[node/timers setImmediate returns Immediate object]", () => {
+ const { clearImmediate, setImmediate } = timers;
+
+ const imm = setImmediate(() => {});
+ imm.unref();
+ imm.ref();
+ imm.hasRef();
+ clearImmediate(imm);
+});