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.js41
1 files changed, 39 insertions, 2 deletions
diff --git a/test/js/web/web-globals.test.js b/test/js/web/web-globals.test.js
index 1a4d7b1d1..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);
@@ -31,6 +31,7 @@ const globalSetters = [
for (const [Constructor, name, eventName, prop] of globalSetters) {
test(`self.${name}`, () => {
var called = false;
+ console.log("name", name);
const callback = ({ [prop]: data }) => {
expect(data).toBe("hello");
@@ -232,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");
+});