aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-03 17:25:25 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-03 17:25:25 -0800
commitde613baf81bfaf524818cb72811e13ad9a3765ff (patch)
tree7ee3116f32e4f8b7ecf73f4c70e4b0078ada51da /test/bun.js
parent4590e2b83acbab63f1516c795f7f79a22f5d3083 (diff)
downloadbun-de613baf81bfaf524818cb72811e13ad9a3765ff.tar.gz
bun-de613baf81bfaf524818cb72811e13ad9a3765ff.tar.zst
bun-de613baf81bfaf524818cb72811e13ad9a3765ff.zip
Support passing `Date` to `Bun.sleep`
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/setTimeout.test.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/bun.js/setTimeout.test.js b/test/bun.js/setTimeout.test.js
index 52430bd03..393a32bbe 100644
--- a/test/bun.js/setTimeout.test.js
+++ b/test/bun.js/setTimeout.test.js
@@ -116,6 +116,14 @@ it("Bun.sleep propagates exceptions", async () => {
}
});
+it("Bun.sleep works with a Date object", async () => {
+ var ten_ms = new Date();
+ ten_ms.setMilliseconds(ten_ms.getMilliseconds() + 10);
+ const now = performance.now();
+ await Bun.sleep(ten_ms);
+ expect(performance.now() - now).toBeGreaterThanOrEqual(10);
+});
+
it("node.js timers/promises setTimeout propagates exceptions", async () => {
const { setTimeout } = require("timers/promises");
try {