import { assertEquals } from "@std/assert"; import { withDom } from "@berry/util/dom.ts"; import { syncRenderers } from "./renderers.ts"; Deno.test("a frontend whose styles alone changed swaps its stylesheets without importing it again", () => withDom(async () => { const module = `data:text/javascript,${encodeURIComponent("export default { tools: {} };")}`; const hrefs = () => [...document.head.querySelectorAll("link")].map((link) => link.getAttribute("href")); try { assertEquals( await syncRenderers([{ name: "probe", formerly: [], web: { module, styles: ["/a.css"] } }]), true, ); assertEquals(hrefs(), ["/a.css"]); assertEquals( await syncRenderers([{ name: "probe", formerly: [], web: { module, styles: ["/b.css"] } }]), false, ); assertEquals(hrefs(), ["/b.css"]); } finally { await syncRenderers([]); } }));