blob: 30748860a4767f477aacae917ea8e42355f682fc (
plain)
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
|
import markdownit from './../markdownit'
import { typesAvailable } from '../markdownit/callouts'
import tableMarkdown from './fixtures/table.md'
import tableHtml from './fixtures/table.html'
describe('markdownit', () => {
it('renders task lists', () => {
const rendered = markdownit.render('* [ ] task\n* not a task')
expect(stripIndent(rendered)).toBe(stripIndent(`
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> task</li>
</ul>
<ul>
<li>not a task</li>
</ul>`
))
})
it('renders bullet and task lists separately', () => {
const rendered = markdownit.render('* not a task\n* [ ] task')
expect(stripIndent(rendered)).toBe(stripIndent(`
<ul>
<li>not a task</li>
</ul>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> task</li>
</ul>
`))
})
it('renders tables', () => {
const rendered = markdownit.render(tableMarkdown)
expect(rendered).toBe(tableHtml)
})
describe('callouts', () => {
typesAvailable.forEach((type) => {
it(`render ${type}`, () => {
const rendered = markdownit.render(`::: ${type}\nHey there!\n:::`)
expect(stripIndent(rendered)).toBe(stripIndent(
`<div data-callout="${type}" class="callout callout-${type}">
<p>Hey there!</p>
</div>`
))
})
})
})
})
function stripIndent(content) {
return content
.replace(/\n/g, "")
.replace(/[\t ]+\</g, "<")
.replace(/\>[\t ]+\</g, "><")
.replace(/\>[\t ]+$/g, ">")
}
|