aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/web-globals.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-17 23:18:18 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-06-22 06:56:47 -0700
commitbe9efacf1bf03fba016bb02f1dd25766fd874033 (patch)
tree9a13f40cb442e3e5d005c5f5b6112b05e626f1c1 /integration/bunjs-only-snippets/web-globals.test.js
parent71025c8bcc68929cea2260d92de03e20a3c898d2 (diff)
downloadbun-be9efacf1bf03fba016bb02f1dd25766fd874033.tar.gz
bun-be9efacf1bf03fba016bb02f1dd25766fd874033.tar.zst
bun-be9efacf1bf03fba016bb02f1dd25766fd874033.zip
WebSocket is a global
Diffstat (limited to 'integration/bunjs-only-snippets/web-globals.test.js')
-rw-r--r--integration/bunjs-only-snippets/web-globals.test.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/web-globals.test.js b/integration/bunjs-only-snippets/web-globals.test.js
index e70e823e8..ac7c22e84 100644
--- a/integration/bunjs-only-snippets/web-globals.test.js
+++ b/integration/bunjs-only-snippets/web-globals.test.js
@@ -12,7 +12,9 @@ test("exists", () => {
expect(typeof Headers !== "undefined").toBe(true);
expect(typeof ErrorEvent !== "undefined").toBe(true);
expect(typeof CloseEvent !== "undefined").toBe(true);
+ expect(typeof MessageEvent !== "undefined").toBe(true);
expect(typeof TextEncoder !== "undefined").toBe(true);
+ expect(typeof WebSocket !== "undefined").toBe(true);
});
test("CloseEvent", () => {
@@ -28,3 +30,17 @@ test("CloseEvent", () => {
target.dispatchEvent(event);
expect(called).toBe(true);
});
+
+test("MessageEvent", () => {
+ var event = new MessageEvent("message", { data: "world" });
+ expect(event.type).toBe("message");
+ const target = new EventTarget();
+ var called = false;
+ target.addEventListener("message", ({ type, data }) => {
+ expect(type).toBe("message");
+ expect(data).toBe("world");
+ called = true;
+ });
+ target.dispatchEvent(event);
+ expect(called).toBe(true);
+});