diff options
author | 2023-02-03 16:33:02 -0800 | |
---|---|---|
committer | 2023-02-03 16:39:16 -0800 | |
commit | 7d386bf1f1c7cbcf58b31fcc4c8e8d945483518e (patch) | |
tree | ebb830f1a3811a03ba480cb5dbdc0295c4bdf987 /test/bun.js/setTimeout.test.js | |
parent | 164cd774f7e8075b1f3a2948c141d27b01f3d542 (diff) | |
download | bun-7d386bf1f1c7cbcf58b31fcc4c8e8d945483518e.tar.gz bun-7d386bf1f1c7cbcf58b31fcc4c8e8d945483518e.tar.zst bun-7d386bf1f1c7cbcf58b31fcc4c8e8d945483518e.zip |
Introduce `await Bun.sleep(ms)`
Diffstat (limited to '')
-rw-r--r-- | test/bun.js/setTimeout.test.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/bun.js/setTimeout.test.js b/test/bun.js/setTimeout.test.js index 9cd16ece2..2670f8519 100644 --- a/test/bun.js/setTimeout.test.js +++ b/test/bun.js/setTimeout.test.js @@ -89,3 +89,18 @@ it("setTimeout(() => {}, 0)", async () => { }); expect(ranFirst).toBe(-1); }); + +it("Bun.sleep", async () => { + var sleeps = 0; + await Bun.sleep(0); + const start = performance.now(); + sleeps++; + await Bun.sleep(1); + sleeps++; + await Bun.sleep(2); + sleeps++; + const end = performance.now(); + expect((end - start) * 1000).toBeGreaterThanOrEqual(3); + + expect(sleeps).toBe(3); +}); |