forked from cloudflare/nimbus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs-root-route-contract.test.ts
More file actions
33 lines (30 loc) · 1.1 KB
/
Copy pathdocs-root-route-contract.test.ts
File metadata and controls
33 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import { fileURLToPath } from "node:url";
import path from "node:path";
const repoRoot = path.resolve(
fileURLToPath(new URL("../../..", import.meta.url)),
);
function source(relativePath: string): string {
return readFileSync(path.join(repoRoot, relativePath), "utf8");
}
test("the shared docs helper maps the root index entry to the catch-all root", () => {
const runtime = source("packages/nimbus-docs/src/runtime.ts");
const getDocsStaticPaths = runtime.slice(
runtime.indexOf("export const getDocsStaticPaths"),
runtime.indexOf("export async function getDocsPageProps"),
);
assert.match(
getDocsStaticPaths,
/params:\s*\{\s*slug:\s*entry\.id === "index" \? undefined : entry\.id\s*\}/,
);
assert.match(
source("packages/nimbus-starter-source/src/pages/[...slug].astro"),
/export const getStaticPaths = getDocsStaticPaths;/,
);
assert.match(
source("apps/www/src/pages/[...slug].astro"),
/export const getStaticPaths = getDocsStaticPaths;/,
);
});