testEveryPageSaysWhatItsAbout
tcmts.site.testEveryPageSaysWhatItsAbout · #4wtrzlbh · function
import { describedIndex, pageList, SOURCES } from "#codebase/tcmts/site";
import assert from "node:assert/strict";
export const testEveryPageSaysWhatItsAbout = () => {
// each page the index lists has its description beside it, and isn't shown its frontmatter
const pages = pageList(SOURCES["docs/README.md"]!);
const rows = SOURCES["docs/README.md"]!.split("\n").filter((l) => l.startsWith("| ["));
assert.equal(rows.length, pages.length - 1);
for (const row of rows) assert.match(row, /^\| \[[^\]]+\]\([^)]+\) \| \S.* \|$/, row);
for (const [src, md] of Object.entries(SOURCES)) assert.doesNotMatch(md, /^---\n/, src);
assert.equal(
describedIndex("| [CLI](cli.md) | |\n| [Kept](x.md) | as written |\n| [None](none.md) |", (s) =>
s === "docs/cli.md" ? "every | command" : s === "docs/x.md" ? "no" : undefined,
),
"| [CLI](cli.md) | every \\| command |\n| [Kept](x.md) | as written |\n| [None](none.md) |",
);
}
uses