testStaticPages
tcmts.cli.web.testStaticPages · #ndbyjvjd · term
import { treeName } from "#codebase/tcmts/cli/rsc";
import { linkedPaths, pageFile } from "#codebase/tcmts/cli/web";
import assert from "node:assert/strict";
export const testStaticPages = () => {
// a page per path, as static hosts serve them
assert.deepEqual(["/", "/today", "/a/b/", "/apps.html", "/caf%C3%A9"].map(pageFile), [
"index.html",
"today.html",
"a/b/index.html",
"apps.html",
"café.html",
]);
// the pages a page links to, as the app follows them
const html = [
'<a href="today">x</a>',
'<a class="tile" href="/x/all?y=1#z" aria-current="page">y</a>',
'<a href="code/a.html" rel="external">not the app\'s</a>',
'<a href="a.tgz">a download</a>',
'<a href="b" download="">a download</a>',
'<a href="c" target="_blank">another tab</a>',
'<a href="/elsewhere">outside the base</a>',
'<a href="https://example.com/x/d">another site</a>',
'<a href="apps.html">a page kept as a file</a>',
'<a href="/x">the base</a>',
].join(" ");
assert.deepEqual(linkedPaths(html, "/x/lists/", "/x"), [
"/lists/today",
"/all",
"/lists/apps.html",
"/",
]);
assert.deepEqual(linkedPaths('<a href="today">', "/", ""), ["/today"]);
// a tree's file is named the same in Node and in the browser (and by every build: pinned), and differently for
// other props
assert.equal(treeName("abc[{}]"), "10907cdb2f2a165d376297e7de20d9e5");
assert.notEqual(treeName("abc[{}]"), treeName('abc[{"a":1}]'));
}
uses