-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmarkdown.test.ts
More file actions
134 lines (83 loc) · 2.55 KB
/
markdown.test.ts
File metadata and controls
134 lines (83 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { validateMarkdown } from "../src/utils/validateMarkdown";
describe("validate markdown", () => {
it("should return false if missing a summary title (#)", () => {
const md = `
Description.
## L1 Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level`;
expect(validateMarkdown(md)).toBe(false);
});
it("should return false if contains multiple `#` headers", () => {
const md1 = `# A Title
Description.
# Another Title
## L1 Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level`;
const md2 = `# A Title
Description.
## L1 Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level
# Another title
`;
expect(validateMarkdown(md1)).toBe(false);
expect(validateMarkdown(md2)).toBe(false);
});
it("should return false if missing a summary description", () => {
const md = `# A Title
## L1 Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level
`;
expect(validateMarkdown(md)).toBe(false);
});
it("should return false if `##` doesn't preface a level", () => {
const md = `# A Title
A description
## Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level
`;
expect(validateMarkdown(md)).toBe(false);
});
it("should return false if `###` doesn't preface a step", () => {
const md = `# A Title
A description
## Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level
### A Step
First step
`;
});
it("should return true for valid markdown", () => {
const md = `# Title
Description.
## L1 Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level
### L1S1
First Step`;
expect(validateMarkdown(md)).toBe(true);
});
it("should ignore markdown content in codeblocks", () => {
const md = `# Title
Description.
\`\`\`md
# A codeblock
Should not be a problem
\`\`\`
## L1 Put Level's title here
> Level's summary: a short description of the level's content in one line.
Some text that describes the level
\`\`\`
## Another Level in markdown
Should not be an issue
\`\`\`
### L1S1
First Step`;
expect(validateMarkdown(md)).toBe(true);
});
});