27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync, existsSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, join } from "node:path";
|
|
|
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
|
// The app, overlays and OBS work offline. The public mobile profile keeps Google Fonts: it is
|
|
// reached over the internet through a router allowlist of three paths (scripts/teltonika).
|
|
test("the app loads its fonts from the repo, not from the internet", () => {
|
|
for (const page of ["index.html"]) {
|
|
const html = readFileSync(join(root, page), "utf8");
|
|
assert.doesNotMatch(html, /fonts\.(googleapis|gstatic)\.com/, page);
|
|
assert.match(html, /href="\/src\/fonts\/fonts\.css"/, page);
|
|
}
|
|
});
|
|
|
|
test("every font file fonts.css points at is in src/fonts, for every family the styles use", () => {
|
|
const css = readFileSync(join(root, "src/fonts/fonts.css"), "utf8");
|
|
const files = [...css.matchAll(/url\("\.\/([^"]+)"\)/g)].map((match) => match[1]);
|
|
assert.ok(files.length >= 15);
|
|
files.forEach((file) => assert.ok(existsSync(join(root, "src/fonts", file)), file));
|
|
["Barlow", "Barlow Condensed", "Orbitron"].forEach((family) => assert.match(css, new RegExp(`font-family: "${family}";`), family));
|
|
assert.ok(existsSync(join(root, "src/fonts/LICENSE")));
|
|
});
|