import { describe, expect, it } from "vitest";
import { hasAuthoredCode, TIMELINE_REGISTRY_SCRIPT } from "./authoredCode";
const page = (head: string, body: string) =>
`
${head}${body}`;
const runtime = '';
const gsap = '';
const still = 'Hi
';
describe("hasAuthoredCode", () => {
it.each([
["a still or CSS-animated composition", page("", still)],
[
"Studio's runtime, GSAP core and registry line",
page(runtime + gsap, TIMELINE_REGISTRY_SCRIPT + still),
],
["an import map", page('', still)],
])("finds none in %s", (_name, html) => {
expect(hasAuthoredCode(html)).toBe(false);
});
it.each([
["an inline script", page("", `${still}`)],
["an upper-case script tag", page("", `${still}`)],
["a script inside an inline SVG", page("", `${still}`)],
[
"a script held until fonts load",
page("", `${still}`),
],
["a script file of the project", page('', still)],
[
"a GSAP plugin file",
page('', still),
],
["an inline event handler", page("", `
${still}`)],
["a frame", page("", `${still}`)],
["a template", page("", `${still}`)],
[
"a child composition loaded at run time",
page("", ''),
],
])("finds %s", (_name, html) => {
expect(hasAuthoredCode(html)).toBe(true);
});
});