| 1 | import { expect, it } from "vitest"; |
| 2 | import { REFERENCE_GUIDES } from "./content/reference-guides"; |
| 3 | import { getReferenceGuide, getReferenceSearchSections } from "./reference-guides"; |
| 4 | |
| 5 | it("canonical references render their source and expose only real section destinations", () => { |
| 6 | for (const spec of REFERENCE_GUIDES) { |
| 7 | const { guide } = getReferenceGuide(spec.slug); |
| 8 | expect(guide.chunks.length).toBeGreaterThan(0); |
| 9 | expect(guide.searchSections.length).toBeGreaterThan(0); |
| 10 | const html = guide.chunks.filter((chunk) => chunk.kind === "html").map((chunk) => chunk.text).join("\n"); |
| 11 | for (const section of guide.searchSections) expect(html).toContain(`id="${section.id}"`); |
| 12 | } |
| 13 | const results = getReferenceSearchSections("zh"); |
| 14 | expect(results.every((result) => result.lang === "en")).toBe(true); |
| 15 | expect(results.some((result) => result.text.includes("previous_seq"))).toBe(true); |
| 16 | expect(results.some((result) => result.href.endsWith("#overview") && result.text.includes("screen-scraping"))).toBe(true); |
| 17 | }); |
| 18 |