-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmarkdown.test.ts
170 lines (105 loc) · 3.05 KB
/
markdown.test.ts
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import { validateMarkdown } from '../src/utils/validateMarkdown'
describe('validate markdown', () => {
it('should return false if missing a summary title (#)', () => {
const md = `
Description.
## 1. 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
## 1. 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.
## 1. 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
## 1. 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
### Missing step id
First step
`
expect(validateMarkdown(md)).toBe(false)
})
it('should return true for valid markdown', () => {
const md = `# Title
Description.
## 1. 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
### 1.1
First Step`
expect(validateMarkdown(md)).toBe(true)
})
it('should allow for empty level content', () => {
const md = `# Title
Description.
## 1. Put Level's title here
### 1.1
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
\`\`\`
## 1. 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
\`\`\`
## 2. Another Level in markdown
Should not be an issue
\`\`\`
### 1.1
First Step`
expect(validateMarkdown(md)).toBe(true)
})
it('should ignore empty space at the top', () => {
const md = `
# Title
Description.`
expect(validateMarkdown(md)).toBe(true)
})
it('should ignore empty space at the bottom', () => {
const md = `
# Title
Description.
`
expect(validateMarkdown(md)).toBe(true)
})
})