-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.test.ts
More file actions
212 lines (173 loc) · 6.45 KB
/
main.test.ts
File metadata and controls
212 lines (173 loc) · 6.45 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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import { expect } from '@std/expect';
import { parse } from './main.ts';
const allFeaturesDisabled = {
bold: false,
headings: false,
horizontalRule: false,
italics: false,
images: false,
links: false,
strikethrough: false,
};
Deno.test('Heading 1', async (test) => {
const config = { ...allFeaturesDisabled, headings: true };
await test.step('Isolated', () => {
const markdown = '# Hello World';
const html = '<h1>Hello World</h1>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'Lorem ipsum\n# Hello World\n1234\n';
const html = 'Lorem ipsum\n<h1>Hello World</h1>\n1234\n';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Heading 2', async (test) => {
const config = { ...allFeaturesDisabled, headings: true };
await test.step('Isolated', () => {
const markdown = '## Hello World';
const html = '<h2>Hello World</h2>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'Lorem ipsum\n## Hello World\n1234\n';
const html = 'Lorem ipsum\n<h2>Hello World</h2>\n1234\n';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Heading 3', async (test) => {
const config = { ...allFeaturesDisabled, headings: true };
await test.step('Isolated', () => {
const markdown = '### Hello World';
const html = '<h3>Hello World</h3>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'Lorem ipsum\n### Hello World\n1234\n';
const html = 'Lorem ipsum\n<h3>Hello World</h3>\n1234\n';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Horizontal Rule', async (test) => {
const config = { ...allFeaturesDisabled, horizontalRule: true };
await test.step('Isolated', () => {
const markdown = '---';
const html = '<hr>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = '# Foo\n---\nbar baz';
const html = '# Foo\n<hr>\nbar baz';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Image', async (test) => {
const config = { ...allFeaturesDisabled, images: true };
await test.step('Isolated', () => {
const markdown = '';
const html = '<img src="https://example.com/image.png" alt="foo">';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'Lorem ipsum  sit amet.';
const html = 'Lorem ipsum <img src="https://example.com/image.png" alt="dolor"> sit amet.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Link', async (test) => {
const config = { ...allFeaturesDisabled, links: true };
await test.step('Isolated', () => {
const markdown = '[link](https://example.com)';
const html = '<a href="https://example.com">link</a>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'Lorem ipsum [dolor](https://example.com) sit amet.';
const html = 'Lorem ipsum <a href="https://example.com">dolor</a> sit amet.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Bold', async (test) => {
const config = { ...allFeaturesDisabled, bold: true };
await test.step('Isolated', () => {
const markdown = '*lorem ipsum dolor*';
const html = '<strong>lorem ipsum dolor</strong>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'lorem ipsum *dolor sit amet*\nconsectetur adipisicing elit.';
const html = 'lorem ipsum <strong>dolor sit amet</strong>\nconsectetur adipisicing elit.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Italics', async (test) => {
const config = { ...allFeaturesDisabled, italics: true };
await test.step('Isolated', () => {
const markdown = '_lorem ipsum dolor_';
const html = '<em>lorem ipsum dolor</em>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'lorem ipsum _dolor sit amet_\nconsectetur adipisicing elit.';
const html = 'lorem ipsum <em>dolor sit amet</em>\nconsectetur adipisicing elit.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Strikethrough', async (test) => {
const config = { ...allFeaturesDisabled, strikethrough: true };
await test.step('Isolated', () => {
const markdown = '~lorem ipsum dolor~';
const html = '<s>lorem ipsum dolor</s>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'lorem ipsum ~dolor sit amet~\nconsectetur adipisicing elit.';
const html = 'lorem ipsum <s>dolor sit amet</s>\nconsectetur adipisicing elit.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Code Block', async (test) => {
const config = { ...allFeaturesDisabled, code: true };
await test.step('Isolated', () => {
const markdown = '```\nlorem\n```';
const html = '<pre><code>lorem</code></pre>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'lorem ipsum\n```\ndolor sit amet\n```\nconsectetur adipisicing elit.';
const html = 'lorem ipsum\n<pre><code>dolor sit amet</code></pre>\nconsectetur adipisicing elit.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Code Inline', async (test) => {
const config = { ...allFeaturesDisabled, code: true };
await test.step('Isolated', () => {
const markdown = '```lorem```';
const html = '<code>lorem</code>';
expect(parse(markdown, config)).toBe(html);
});
await test.step('Integrated', () => {
const markdown = 'lorem ipsum ```dolor sit amet``` consectetur adipisicing elit.';
const html = 'lorem ipsum <code>dolor sit amet</code> consectetur adipisicing elit.';
expect(parse(markdown, config)).toBe(html);
});
});
Deno.test('Breaks', async (test) => {
const config = { ...allFeaturesDisabled, breaks: true };
await test.step('Isolated', () => {
const markdown1 = ' \n';
const html1 = '<br>';
expect(parse(markdown1, config)).toBe(html1);
const markdown2 = '\n\n';
const html2 = '<br>';
expect(parse(markdown2, config)).toBe(html2);
});
await test.step('Integrated', () => {
const markdown1 = 'lorem ipsum dolor \n';
const html1 = 'lorem ipsum dolor<br>';
expect(parse(markdown1, config)).toBe(html1);
const markdown2 = 'lorem ipsum dolor\n\n';
const html2 = 'lorem ipsum dolor<br>';
expect(parse(markdown2, config)).toBe(html2);
});
});