|
| 1 | +import fs from "node:fs"; |
| 2 | +import path from "node:path"; |
1 | 3 | import { createElement } from "react"; |
2 | 4 | import { renderToStaticMarkup } from "react-dom/server"; |
3 | 5 | import matter from "gray-matter"; |
@@ -36,7 +38,29 @@ describe("static discovery content", () => { |
36 | 38 | }); |
37 | 39 |
|
38 | 40 | it("preserves upstream architecture content", () => { |
39 | | - const source = matter(articles.getMarkdownContent("architecture")); |
| 41 | + const markdown = `--- |
| 42 | +title: Upstream architecture |
| 43 | +description: Architecture documentation from upstream. |
| 44 | +layout: coming-soon |
| 45 | +--- |
| 46 | +
|
| 47 | +Architecture details will be published here. |
| 48 | +`; |
| 49 | + const directory = path.join(process.cwd(), "articles", "architecture"); |
| 50 | + const files = new Map([ |
| 51 | + [path.join(directory, "index.md"), markdown], |
| 52 | + [path.join(directory, "navigation.yml"), "- title: Architecture\n link: index.md\n"], |
| 53 | + ]); |
| 54 | + const existsSync = fs.existsSync; |
| 55 | + const readFileSync = fs.readFileSync; |
| 56 | + vi.spyOn(fs, "existsSync").mockImplementation((file) => |
| 57 | + files.has(file.toString()) || existsSync(file), |
| 58 | + ); |
| 59 | + vi.spyOn(fs, "readFileSync").mockImplementation((file, options) => |
| 60 | + files.get(file.toString()) ?? readFileSync(file, options), |
| 61 | + ); |
| 62 | + |
| 63 | + const source = matter(markdown); |
40 | 64 | const architecture = articles.getArticleByPath("architecture"); |
41 | 65 | expect(architecture?.content).toBe(source.content); |
42 | 66 | expect(architecture?.frontmatter).toEqual(source.data); |
|
0 commit comments