aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/web-globals.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/web/web-globals.test.js')
-rw-r--r--test/js/web/web-globals.test.js40
1 files changed, 38 insertions, 2 deletions
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");
+});