Skip to content

Commit bb992fa

Browse files
committed
test(md): add hyperlink tests for single-file and multi-doc modes
Cover anchor-only links within the same file, cross-file links to other documents, and hyperlinked view includes in README.
1 parent 54dde87 commit bb992fa

1 file changed

Lines changed: 54 additions & 5 deletions

File tree

tests/json-to-md.unit.test.ts

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,27 @@ describe("json-to-md single file", () => {
346346
it("renders view includes", () => {
347347
const md = jsonToMarkdownSingle(full());
348348
assert.ok(md.includes("Includes:"));
349-
assert.ok(md.includes("- INT1"));
350-
assert.ok(md.includes("- CON1"));
349+
});
350+
351+
it("hyperlinks relationship targets to anchor headings", () => {
352+
const md = jsonToMarkdownSingle(full());
353+
// CON1 refines INT1 — anchor-only link in single file
354+
assert.ok(
355+
md.includes("[INT1](#int1--test-intent)"),
356+
`Expected anchor link to INT1 in single file, got:\n${md}`,
357+
);
358+
});
359+
360+
it("hyperlinks view includes to anchor headings", () => {
361+
const md = jsonToMarkdownSingle(full());
362+
assert.ok(
363+
md.includes("[INT1](#int1--test-intent)"),
364+
`Expected anchor link to INT1 in view includes`,
365+
);
366+
assert.ok(
367+
md.includes("[CON1](#con1--test-concept)"),
368+
`Expected anchor link to CON1 in view includes`,
369+
);
351370
});
352371

353372
it("renders multiline descriptions as separate lines", () => {
@@ -470,9 +489,11 @@ describe("json-to-md multi-doc", () => {
470489
it("renders node relationships in the correct file", () => {
471490
jsonToMarkdownMultiDoc(full(), tmpDir);
472491
const intent = readFileSync(join(tmpDir, "INTENT.md"), "utf8");
473-
assert.ok(intent.includes("Refines: INT1"));
492+
assert.ok(intent.includes("Refines:"));
493+
assert.ok(intent.includes("INT1"));
474494
const state = readFileSync(join(tmpDir, "STATE.md"), "utf8");
475-
assert.ok(state.includes("Realises: CAP1"));
495+
assert.ok(state.includes("Realises:"));
496+
assert.ok(state.includes("CAP1"));
476497
});
477498

478499
it("README contains external references", () => {
@@ -485,7 +506,35 @@ describe("json-to-md multi-doc", () => {
485506
jsonToMarkdownMultiDoc(full(), tmpDir);
486507
const readme = readFileSync(join(tmpDir, "README.md"), "utf8");
487508
assert.ok(readme.includes("### VIEW1 — Domain View"));
488-
assert.ok(readme.includes("- INT1"));
509+
});
510+
511+
it("hyperlinks relationship targets to their node headings", () => {
512+
jsonToMarkdownMultiDoc(full(), tmpDir);
513+
const intent = readFileSync(join(tmpDir, "INTENT.md"), "utf8");
514+
// CON1 refines INT1 — same file, so anchor-only link
515+
assert.ok(
516+
intent.includes("[INT1](#int1--test-intent)"),
517+
`Expected anchor link to INT1 in INTENT.md, got:\n${intent}`,
518+
);
519+
const state = readFileSync(join(tmpDir, "STATE.md"), "utf8");
520+
// ELEM1 realises CAP1 — cross-file link to INTENT.md
521+
assert.ok(
522+
state.includes("[CAP1](./INTENT.md#cap1--test-capability)"),
523+
`Expected cross-file link to CAP1 in STATE.md, got:\n${state}`,
524+
);
525+
});
526+
527+
it("hyperlinks view includes to their node headings", () => {
528+
jsonToMarkdownMultiDoc(full(), tmpDir);
529+
const readme = readFileSync(join(tmpDir, "README.md"), "utf8");
530+
assert.ok(
531+
readme.includes("[INT1](./INTENT.md#int1--test-intent)"),
532+
`Expected hyperlinked INT1 in view includes, got:\n${readme}`,
533+
);
534+
assert.ok(
535+
readme.includes("[CON1](./INTENT.md#con1--test-concept)"),
536+
`Expected hyperlinked CON1 in view includes, got:\n${readme}`,
537+
);
489538
});
490539

491540
it("creates subsystem folders", () => {

0 commit comments

Comments
 (0)