Files
mangabaka-seeder/test/template.test.ts
T

19 lines
893 B
TypeScript

import { expect, test } from "bun:test";
import { APP_HTML } from "../src/web/template";
test("every element app.ts looks up exists in the template exactly once", async () => {
const app = await Bun.file("src/web/app.ts").text();
const wanted = [...app.matchAll(/\bq<[^>]+>\("([a-z-]+)"\)/g)].map((m) => m[1]!);
expect(wanted.length).toBeGreaterThan(30);
for (const id of wanted) {
expect({ id, count: APP_HTML.split(`id="${id}"`).length - 1 }).toEqual({ id, count: 1 });
}
});
test("analytics: on the page only, never in the panel the userscript mounts on mangabaka.org", async () => {
const page = await Bun.file("src/web/index.html").text();
expect(page).toContain('<script defer src="https://analytics.lucaswinther.info/ingress/');
expect(APP_HTML).not.toContain("analytics");
expect(await Bun.file("src/userscript/main.ts").text()).not.toContain("analytics");
});