diff options
Diffstat (limited to 'integration/bunjs-only-snippets/web-globals.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/web-globals.test.js | 16 |
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); +}); |