import { describe, expect, it } from "vitest";
import {
injectScriptsAtHeadStart,
injectScriptsIntoHtml,
parseHTMLContent,
stripEmbeddedRuntimeScripts,
} from "./htmlDocument.js";
describe("htmlDocument helpers", () => {
it("wraps fragments before parsing", () => {
const doc = parseHTMLContent("hello");
expect(doc.body.querySelector("template")?.innerHTML).toContain("hello");
});
it("strips every known embedded HyperFrames runtime marker", () => {
const html = `
`;
const stripped = stripEmbeddedRuntimeScripts(html);
expect(stripped).not.toContain("hyperframe.runtime.iife.js");
expect(stripped).not.toContain("hyperframes-runtime.modular.inline.js");
expect(stripped).not.toContain("hyperframe-runtime.modular-runtime.inline.js");
expect(stripped).not.toContain("data-hyperframes-preview-runtime");
expect(stripped).not.toContain("window.__playerReady");
expect(stripped).toContain("window.authored = true");
});
it("does not treat non-script tags as scripts when stripping runtimes", () => {
const html = "
"); }); it("injects early head scripts before authored head scripts", () => { const html = '