Skip to content

Commit fda9b35

Browse files
authored
test: cover index page generation (#468)
1 parent 65c179d commit fda9b35

File tree

4 files changed

+5515
-781
lines changed

4 files changed

+5515
-781
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
node-version-file: ".nvmrc"
2525
- run: npm install
2626
- run: npm run lint
27+
- run: npm test
2728

2829
indexpage:
2930
name: Index Page

__tests__/generate_index.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { execFileSync } from "child_process";
2+
import fs from "fs";
3+
import os from "os";
4+
import path from "path";
5+
import { fileURLToPath } from "url";
6+
7+
const script = fileURLToPath(new URL("../generate_index.js", import.meta.url));
8+
9+
test("index generation includes headings", () => {
10+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "talks-test-"));
11+
fs.writeFileSync(
12+
path.join(tmp, "schedule.md"),
13+
`| Date | Talk | Where |
14+
| --- | --- | --- |
15+
| 2099-01-01 | The Future | (v)[Future](https://example.com) |
16+
| 2000-01-01 | The Past | (v)[Past](https://example.com) |
17+
`,
18+
);
19+
fs.writeFileSync(
20+
path.join(tmp, "demo.md"),
21+
"title: Demo Talk\ndescription: Something\n",
22+
);
23+
const output = execFileSync("node", [script], {
24+
cwd: tmp,
25+
});
26+
const html = output.toString();
27+
expect(html).toContain("Upcoming talks");
28+
expect(html).toContain("Previous talks");
29+
});

0 commit comments

Comments
 (0)