diff options
author | 2023-01-31 17:51:36 -0800 | |
---|---|---|
committer | 2023-01-31 17:51:36 -0800 | |
commit | b09896f06ec81e606a7f7e344d2ac45a5e1ffd39 (patch) | |
tree | c7efa26435eaa873859719f81d78e0cf5c1c7441 /test/bun.js/node-timers.test.ts | |
parent | b7816f3175362271d4569d64e33a193998268cab (diff) | |
download | bun-b09896f06ec81e606a7f7e344d2ac45a5e1ffd39.tar.gz bun-b09896f06ec81e606a7f7e344d2ac45a5e1ffd39.tar.zst bun-b09896f06ec81e606a7f7e344d2ac45a5e1ffd39.zip |
mostly fix `node:timers`
Diffstat (limited to 'test/bun.js/node-timers.test.ts')
-rw-r--r-- | test/bun.js/node-timers.test.ts | 26 |
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); + }); + }); +} |