Files

68 lines
1.9 KiB
TypeScript
Raw Permalink Normal View History

2026-06-30 20:57:55 +10:00
import { describe, it } from "node:test";
import { expect } from "expect";
2026-05-09 17:58:44 +10:00
import { createTempRepo } from "../helpers/temp-repo.js";
import { parseMarkdownDocument } from "../../src/markdown/parse.js";
import { resolveAuthorityPaths } from "../../src/routing/authority.js";
describe("parseMarkdownDocument", () => {
it("extracts frontmatter, headings, and internal links", () => {
const document = parseMarkdownDocument(`---
status: active
---
# Authentication
See [Auth API](docs/api/authentication.md) and [anchor](#timeouts).
## Timeouts
Ignore [external](https://example.com).
`);
expect(document.frontmatter).toMatchObject({
status: "active",
});
expect(document.headings).toEqual([
{ depth: 1, text: "Authentication" },
{ depth: 2, text: "Timeouts" },
]);
2026-06-30 20:57:55 +10:00
expect(document.internalLinks).toEqual([
"docs/api/authentication.md",
"#timeouts",
]);
2026-05-09 17:58:44 +10:00
});
});
describe("resolveAuthorityPaths", () => {
it("preserves declared authority order while expanding globs deterministically", async () => {
const repo = await createTempRepo();
try {
2026-06-30 20:57:55 +10:00
await repo.writeFile(
"docs/truthmark/routes/areas.md",
"# Truthmark Areas\n",
);
2026-05-09 17:58:44 +10:00
await repo.writeFile("docs/guides/beta.md", "# Beta\n");
await repo.writeFile("docs/guides/alpha.md", "# Alpha\n");
await repo.writeFile("docs/api/authentication.md", "# Auth API\n");
const result = await resolveAuthorityPaths(repo.rootDir, [
"docs/truthmark/routes/areas.md",
2026-05-09 17:58:44 +10:00
"docs/guides/*.md",
"docs/api/*.md",
]);
expect(result.diagnostics).toEqual([]);
expect(result.paths).toEqual([
"docs/truthmark/routes/areas.md",
2026-05-09 17:58:44 +10:00
"docs/guides/alpha.md",
"docs/guides/beta.md",
"docs/api/authentication.md",
]);
} finally {
await repo.cleanup();
}
});
});