aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/node-timers.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/node-timers.test.ts')
-rw-r--r--test/bun.js/node-timers.test.ts26
1 files changed, 16 insertions, 10 deletions
diff --git a/test/bun.js/node-timers.test.ts b/test/bun.js/node-timers.test.ts
index f1a8ae802..e6fa48010 100644
--- a/test/bun.js/node-timers.test.ts
+++ b/test/bun.js/node-timers.test.ts
@@ -1,11 +1,17 @@
-import { test } from "bun:test";
-import { setTimeout } from "node:timers";
+import { describe, test } from "bun:test";
+import { setTimeout, clearTimeout, setInterval, setImmediate } from "node:timers";
-// not implemented yet
-// test("unref is possible", () => {
-// const timer = setTimeout(() => {
-// throw new Error("should not be called");
-// }, 1000);
-// timer.unref();
-// clearTimeout(timer);
-// });
+for (const fn of [setTimeout, setInterval, setImmediate]) {
+ describe(fn.name, () => {
+ test("unref is possible", done => {
+ const timer = fn(() => {
+ done(new Error("should not be called"));
+ }, 1);
+ fn(() => {
+ done();
+ }, 2);
+ timer.unref();
+ if (fn !== setImmediate) clearTimeout(timer);
+ });
+ });
+}