import assert from "node:assert/strict"; import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { test } from "node:test"; import { inlineGsap, inlineGsapInProject } from "./ci/inline-gsap.mjs"; const TAG = ''; test("a GSAP CDN tag becomes the script itself and other tags stay", () => { const html = `${TAG}`; const out = inlineGsap(html, "var gsap=1;"); assert.equal( out, '', ); }); test("every html file of a project is rewritten, and a project with no tag fails", () => { const dir = mkdtempSync(join(tmpdir(), "inline-gsap-")); try { mkdirSync(join(dir, "compositions")); writeFileSync(join(dir, "index.html"), `${TAG}`); writeFileSync(join(dir, "compositions", "a.html"), ``); assert.equal(inlineGsapInProject(dir, "G;"), 2); assert.equal(readFileSync(join(dir, "index.html"), "utf8"), ""); assert.throws(() => inlineGsapInProject(dir, "G;"), /no GSAP CDN script tag/); } finally { rmSync(dir, { recursive: true, force: true }); } });