-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmarkdownFormatter.test.ts
186 lines (159 loc) · 2.94 KB
/
markdownFormatter.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import { ADFEntity, formatAdf, markdownFormatter } from '../src';
import {
blockquoteAdf,
inlineCodeAdf,
headingsAdf,
textMarkupAdf,
linkAdf,
codeBlockAdf,
tablesAdf,
largerAdf,
bulletListAdf,
orderedListAdf,
} from './adf.fixtures';
describe(`Markdown formatting`, () => {
const tests: { feature: string; adf: ADFEntity; expectedMd: string }[] = [
{
feature: 'quotes',
adf: blockquoteAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd: `A quote follows.
> Honk
The end.
`,
},
{
feature: 'headings',
adf: headingsAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd: `
# Heading 1
Text 1
## Heading 2
Text 1.1
### Heading 3
Text 1.1.1
#### Heading 4
Text 1.1.1.1
Text 1.1.1.2
##### Heading 5
Text 1.1.1.1.1
###### Heading 6
Text 1.1.1.1.1.1
`,
},
{
feature: 'text markup',
adf: textMarkupAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd: `regular
*italic*
<u>underlined</u>
~~strikethrough~~
**bold**
sub<sub>script</sub>
super<sup>script</sup>
~~***eve***~~<sub>~~***ry***~~</sub>~~***thi***~~<sup>~~***ng***~~</sup>
`,
},
{
feature: 'links',
adf: linkAdf,
expectedMd: 'Go to [Dixa](https://dixa.com)!\n',
},
{
feature: 'inline code',
adf: inlineCodeAdf,
expectedMd: 'Hello `code`.\n',
},
{
feature: 'unordered lists',
adf: bulletListAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd:`
- one
- two
- nine
`,
},
{
feature: 'ordered lists',
adf: orderedListAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd:`
1. one
1. two
1. nine
`,
},
{
feature: 'code blocks',
adf: codeBlockAdf,
expectedMd: 'Code follows.\n\n```\n10 PRINT "hah hah"\n20 GOTO 10\n```\n',
},
{
feature: 'tables',
adf: tablesAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd: `<table>
<tr>
<th>A
<th>B
<tr>
<td>A:1
<td>B:1
<tr>
<td>A:2
<td>B:2
</table>
`,
},
{
feature: 'larger documents',
adf: largerAdf,
// Prevent prettier from messing up multiline strings
// prettier-ignore
expectedMd: `
# ADF Test
## Text
Text **with** *markup*
## Lists
- un-
- ordered
- list
1. numbered
1. list
## Links
[https://xkcd.com](https://xkcd.com)
## Tables
<table>
<tr>
<th>I
<th>hate
<tr>
<td>tables
<td>in
<tr>
<td>markdown
<td>a lot
</table>
## Code
Inline \`code\` and
\`\`\`typescript
// a code block
(code) => 'blocks'
\`\`\`
`,
},
];
it.each(tests)('should support $feature', (test) => {
const result = formatAdf(test.adf, markdownFormatter);
expect(result).toEqual(test.expectedMd);
});
});