Skip to content

Commit 994c66e

Browse files
committed
fixture and tests
1 parent 0c8371e commit 994c66e

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Fixtures
3+
noindex: true
4+
sidebar:
5+
hidden: true
6+
---
7+
8+
This folder stores test fixtures to be used in CI.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Markdown
3+
noindex: true
4+
sidebar:
5+
hidden: true
6+
---
7+
8+
import { Tabs, TabItem } from "~/components";
9+
10+
The HTML generated by this file is used as a test fixture for our Markdown generation.
11+
12+
<Tabs>
13+
<TabItem label="mdx">
14+
```mdx
15+
test
16+
```
17+
</TabItem>
18+
<TabItem label="md">
19+
```md
20+
test
21+
```
22+
</TabItem>
23+
</Tabs>

vitest.workspace.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ const workspace = defineWorkspace([
88
test: {
99
name: "Workers",
1010
include: ["**/*.worker.test.ts"],
11+
deps: {
12+
optimizer: {
13+
ssr: {
14+
enabled: true,
15+
include: ["node-html-parser"],
16+
},
17+
},
18+
},
1119
poolOptions: {
1220
workers: {
1321
wrangler: { configPath: "./wrangler.toml" },

worker/index.worker.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,40 @@ describe("Cloudflare Docs", () => {
247247
expect(text).toContain('from "~/components"');
248248
});
249249
});
250+
251+
describe("index.md handling", () => {
252+
it("style-guide fixture", async () => {
253+
const request = new Request(
254+
"http://fakehost/style-guide/fixtures/markdown/index.md",
255+
);
256+
const response = await SELF.fetch(request);
257+
258+
expect(response.status).toBe(200);
259+
260+
const text = await response.text();
261+
expect(text).toMatchInlineSnapshot(`
262+
"The HTML generated by this file is used as a test fixture for our Markdown generation.
263+
264+
* mdx
265+
266+
\`\`\`mdx
267+
test
268+
\`\`\`
269+
270+
* md
271+
272+
\`\`\`md
273+
test
274+
\`\`\`
275+
"
276+
`);
277+
});
278+
279+
it("responds with 404.html at `/non-existent/index.md`", async () => {
280+
const request = new Request("http://fakehost/non-existent/index.md");
281+
const response = await SELF.fetch(request);
282+
expect(response.status).toBe(404);
283+
expect(await response.text()).toContain("Page not found.");
284+
});
285+
});
250286
});

0 commit comments

Comments
 (0)