diff options
author | 2023-07-05 03:46:10 -0700 | |
---|---|---|
committer | 2023-07-05 03:46:10 -0700 | |
commit | 3aaec120e7ac26b3904895d2783a08352b63201a (patch) | |
tree | 7cc846f9ed6f12fcf4384d6794591a9506d01a76 /test/js/node/timers/node-timers.test.ts | |
parent | c864976da6140c1c92dae8472b1813a1eca8a78c (diff) | |
download | bun-3aaec120e7ac26b3904895d2783a08352b63201a.tar.gz bun-3aaec120e7ac26b3904895d2783a08352b63201a.tar.zst bun-3aaec120e7ac26b3904895d2783a08352b63201a.zip |
Fixes #3512 (#3526)
* Fixes #3512
* Fix `clearTimeout` and `clearInterval` not cancelling jobs same-tick
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/js/node/timers/node-timers.test.ts')
-rw-r--r-- | test/js/node/timers/node-timers.test.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/js/node/timers/node-timers.test.ts b/test/js/node/timers/node-timers.test.ts index e6fa48010..412eabc22 100644 --- a/test/js/node/timers/node-timers.test.ts +++ b/test/js/node/timers/node-timers.test.ts @@ -1,17 +1,18 @@ import { describe, test } from "bun:test"; -import { setTimeout, clearTimeout, setInterval, setImmediate } from "node:timers"; +import { setTimeout, clearTimeout, setInterval, clearInterval, setImmediate } from "node:timers"; -for (const fn of [setTimeout, setInterval, setImmediate]) { +for (const fn of [setTimeout, setInterval]) { describe(fn.name, () => { test("unref is possible", done => { const timer = fn(() => { done(new Error("should not be called")); - }, 1); - fn(() => { + }, 1).unref(); + const other = fn(() => { + clearInterval(other); done(); }, 2); - timer.unref(); - if (fn !== setImmediate) clearTimeout(timer); + if (fn === setTimeout) clearTimeout(timer); + if (fn === setInterval) clearInterval(timer); }); }); } |