import { expect, test } from "bun:test"; import { getIslandRuntime } from "../src/runtime-source.ts"; test("emits a runtime that bails out when no island markers exist", () => { const source = getIslandRuntime(false); expect(source).toContain("data-wrn-island"); expect(source).toContain("/__wrnexus/island/"); }); test("registers a navigation hook so islands unmount on route change", () => { expect(getIslandRuntime(false)).toContain("__wrnexusUnmountIslands"); }); test("never references react-dom/server", () => { expect(getIslandRuntime(true)).not.toContain("react-dom/server"); }); test("threads the development flag into the mount options", () => { expect(getIslandRuntime(true)).toContain("development: true"); expect(getIslandRuntime(false)).toContain("development: false"); }); test("encodes the island name before using it as a URL path segment", () => { expect(getIslandRuntime(false)).toContain("encodeURIComponent"); }); test("the runtime remounts islands after an HMR update", () => { // HMR morphs the server placeholder over the mounted island, discarding the // React tree; without this the island silently disappears on every edit. const source = getIslandRuntime(true); expect(source).toContain("wrnexus:hmr-updated"); expect(source).toContain("__wrnexusRemountIslands"); });