diff options
author | 2023-09-24 03:16:51 -0700 | |
---|---|---|
committer | 2023-09-24 03:16:51 -0700 | |
commit | b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5 (patch) | |
tree | 079b1582e92fbe67f3b52929ac34015da0cecb55 /test/js | |
parent | a5908e9f2704f801587115007c2bec5788bd718a (diff) | |
download | bun-b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5.tar.gz bun-b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5.tar.zst bun-b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5.zip |
Fixes #5985 (#5986)
* Fixes #5985
* Update confirm-fixture.js
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/web/confirm-fixture.js | 3 | ||||
-rw-r--r-- | test/js/web/web-globals.test.js | 40 |
2 files changed, 41 insertions, 2 deletions
diff --git a/test/js/web/confirm-fixture.js b/test/js/web/confirm-fixture.js new file mode 100644 index 000000000..908570bce --- /dev/null +++ b/test/js/web/confirm-fixture.js @@ -0,0 +1,3 @@ +const result = confirm("What is your answer?"); + +console.error(result ? "Yes" : "No"); diff --git a/test/js/web/web-globals.test.js b/test/js/web/web-globals.test.js index abcad63f7..74b28c0b0 100644 --- a/test/js/web/web-globals.test.js +++ b/test/js/web/web-globals.test.js @@ -1,6 +1,6 @@ -import { unsafe } from "bun"; +import { spawn } from "bun"; import { expect, it, test } from "bun:test"; -import { withoutAggressiveGC } from "harness"; +import { bunEnv, bunExe, withoutAggressiveGC } from "harness"; test("exists", () => { expect(typeof URL !== "undefined").toBe(true); @@ -233,3 +233,39 @@ test("navigator", () => { expect(navigator.platform).toBe("Linux x86_64"); } }); + +test("confirm (yes)", async () => { + const proc = spawn({ + cmd: [bunExe(), require("path").join(import.meta.dir, "./confirm-fixture.js")], + stderr: "pipe", + stdin: "pipe", + stdout: "pipe", + env: bunEnv, + }); + + proc.stdin.write("Y"); + await proc.stdin.flush(); + + proc.stdin.write("\n"); + await proc.stdin.flush(); + + await proc.exited; + + expect(await new Response(proc.stderr).text()).toBe("Yes\n"); +}); + +test("confirm (no)", async () => { + const proc = spawn({ + cmd: [bunExe(), require("path").join(import.meta.dir, "./confirm-fixture.js")], + stderr: "pipe", + stdin: "pipe", + stdout: "pipe", + env: bunEnv, + }); + + proc.stdin.write("poask\n"); + await proc.stdin.flush(); + await proc.exited; + + expect(await new Response(proc.stderr).text()).toBe("No\n"); +}); |