Skip to content

Commit d4916da

Browse files
committed
setup validate markdown tests
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent e15cc9f commit d4916da

File tree

1 file changed

+99
-7
lines changed

1 file changed

+99
-7
lines changed

tests/markdown.test.ts

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,103 @@
1-
import * as T from "../typings/tutorial";
21
import { validateMarkdown } from "../src/utils/validateMarkdown";
32

43
describe("validate markdown", () => {
5-
it.todo("should return false if missing a summary title (#)");
6-
it.todo("should return false if contains multiple `#` headers");
7-
it.todo("should return false if missing a summary description");
8-
it.todo("should return false if `##` doesn't preface a level");
9-
it.todo("should return false if `###` doesn't preface a step");
10-
it.todo("should return true for valid markdown");
4+
it("should return false if missing a summary title (#)", () => {
5+
const md = `
6+
Description.
7+
8+
## L1 Put Level's title here
9+
10+
> Level's summary: a short description of the level's content in one line.
11+
12+
Some text that describes the level`;
13+
expect(validateMarkdown(md)).toBe(false);
14+
});
15+
16+
it("should return false if contains multiple `#` headers", () => {
17+
const md1 = `# A Title
18+
Description.
19+
20+
# Another Title
21+
22+
## L1 Put Level's title here
23+
24+
> Level's summary: a short description of the level's content in one line.
25+
26+
Some text that describes the level`;
27+
28+
const md2 = `# A Title
29+
Description.
30+
31+
32+
## L1 Put Level's title here
33+
34+
> Level's summary: a short description of the level's content in one line.
35+
36+
Some text that describes the level
37+
38+
# Another title
39+
`;
40+
expect(validateMarkdown(md1)).toBe(false);
41+
expect(validateMarkdown(md2)).toBe(false);
42+
});
43+
44+
it("should return false if missing a summary description", () => {
45+
const md = `# A Title
46+
47+
## L1 Put Level's title here
48+
49+
> Level's summary: a short description of the level's content in one line.
50+
51+
Some text that describes the level
52+
`;
53+
expect(validateMarkdown(md)).toBe(false);
54+
});
55+
56+
it("should return false if `##` doesn't preface a level", () => {
57+
const md = `# A Title
58+
59+
A description
60+
61+
## Put Level's title here
62+
63+
> Level's summary: a short description of the level's content in one line.
64+
65+
Some text that describes the level
66+
`;
67+
expect(validateMarkdown(md)).toBe(false);
68+
});
69+
70+
it("should return false if `###` doesn't preface a step", () => {
71+
const md = `# A Title
72+
73+
A description
74+
75+
## Put Level's title here
76+
77+
> Level's summary: a short description of the level's content in one line.
78+
79+
Some text that describes the level
80+
81+
### A Step
82+
83+
First step
84+
`;
85+
});
86+
87+
it("should return true for valid markdown", () => {
88+
const md = `# Title
89+
90+
Description.
91+
92+
## L1 Put Level's title here
93+
94+
> Level's summary: a short description of the level's content in one line.
95+
96+
Some text that describes the level
97+
98+
### L1S1
99+
100+
First Step`;
101+
expect(validateMarkdown(md)).toBe(true);
102+
});
11103
});

0 commit comments

Comments
 (0)