From c4bb085ff485f449a0e465abc6d5f097c1165f62 Mon Sep 17 00:00:00 2001 From: Tyler Barker Date: Sat, 4 Jan 2025 16:51:36 +1100 Subject: [PATCH] try globalThis instead of global --- .../test/integration/event.test.js | 2 +- .../test/integration/metadata.test.js | 2 +- packages/phoenix_live_view_ts/test/utils.test.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/phoenix_live_view_ts/test/integration/event.test.js b/packages/phoenix_live_view_ts/test/integration/event.test.js index 8e66701..5bfbe81 100644 --- a/packages/phoenix_live_view_ts/test/integration/event.test.js +++ b/packages/phoenix_live_view_ts/test/integration/event.test.js @@ -28,7 +28,7 @@ const prepareLiveViewDOM = (document, rootId) => { describe("events", () => { beforeEach(() => { - prepareLiveViewDOM(global.document, "root"); + prepareLiveViewDOM(globalThis.document, "root"); }); test("send change event to correct target", () => { diff --git a/packages/phoenix_live_view_ts/test/integration/metadata.test.js b/packages/phoenix_live_view_ts/test/integration/metadata.test.js index 44ac585..c8c71dd 100644 --- a/packages/phoenix_live_view_ts/test/integration/metadata.test.js +++ b/packages/phoenix_live_view_ts/test/integration/metadata.test.js @@ -22,7 +22,7 @@ const prepareLiveViewDOM = (document, rootId) => { describe("metadata", () => { beforeEach(() => { - prepareLiveViewDOM(global.document, "root"); + prepareLiveViewDOM(globalThis.document, "root"); }); test("is empty by default", () => { diff --git a/packages/phoenix_live_view_ts/test/utils.test.js b/packages/phoenix_live_view_ts/test/utils.test.js index c8aaeb4..09d1734 100644 --- a/packages/phoenix_live_view_ts/test/utils.test.js +++ b/packages/phoenix_live_view_ts/test/utils.test.js @@ -1,14 +1,14 @@ import { describe, expect, test } from "bun:test"; import { Socket } from "phoenix_ts"; -import { closestPhxBinding } from "../src/utils"; import { LiveSocket } from "../assets/js/phoenix_live_view"; +import { closestPhxBinding } from "../src/utils"; -import {simulateJoinedView, liveViewDOM} from "./test_helpers" +import {liveViewDOM, simulateJoinedView } from "./test_helpers" let setupView = (content) => { let el = liveViewDOM(content) - global.document.body.appendChild(el) + globalThis.document.body.appendChild(el) let liveSocket = new LiveSocket("/live", Socket) return simulateJoinedView(el, liveSocket) } @@ -21,8 +21,8 @@ describe("utils", () => { This is a button `) - let element = global.document.querySelector("#innerContent") - let parent = global.document.querySelector("#button") + let element = globalThis.document.querySelector("#innerContent") + let parent = globalThis.document.querySelector("#button") expect(closestPhxBinding(element, "phx-click")).toBe(parent) }) @@ -32,7 +32,7 @@ describe("utils", () => { This is a button `) - let element = global.document.querySelector("#innerContent") + let element = globalThis.document.querySelector("#innerContent") expect(closestPhxBinding(element, "phx-click")).toBe(null) }) })