This repository was archived by the owner on May 12, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathmarkdown.test.js
More file actions
140 lines (116 loc) · 4.46 KB
/
Copy pathmarkdown.test.js
File metadata and controls
140 lines (116 loc) · 4.46 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
jest.mock(
'electron',
() => {
return {
remote: {
app: {
getPath: jest.fn().mockReturnValue('.')
}
}
}
},
{ virtual: true }
)
import Markdown from 'browser/lib/markdown'
import markdownFixtures from '../fixtures/markdowns'
// basic markdown instance which meant to be used in every test cases.
// To test markdown options, initialize a new instance in your test case
const md = new Markdown()
test('Markdown.render() should renders markdown correctly', () => {
const rendered = md.render(markdownFixtures.basic)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should renders codeblock correctly', () => {
const rendered = md.render(markdownFixtures.codeblock)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should escape fenced html when sanitization is disabled', () => {
const markdown = [
'<section data-raw="true">raw html</section>',
'',
'```html',
'<div',
' class="button"',
' data-action="save">',
' keep me',
'</div>',
'```'
].join('\n')
const rendered = new Markdown({ sanitize: 'NONE' }).render(markdown)
expect(rendered).toContain('<section data-raw="true">raw html</section>')
expect(rendered).toContain('<div')
expect(rendered).toContain('class="button"')
expect(rendered).toContain('data-action="save">')
expect(rendered).toContain('</div>')
expect(rendered).not.toContain('<div\n class')
})
test('Markdown.render() should renders KaTeX correctly', () => {
const rendered = md.render(markdownFixtures.katex)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should renders checkboxes', () => {
const rendered = md.render(markdownFixtures.checkboxes)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should text with quotes correctly', () => {
const renderedSmartQuotes = md.render(markdownFixtures.smartQuotes)
expect(renderedSmartQuotes).toMatchSnapshot()
const newmd = new Markdown({ typographer: false })
const renderedNonSmartQuotes = newmd.render(markdownFixtures.smartQuotes)
expect(renderedNonSmartQuotes).toMatchSnapshot()
})
test('Markdown.render() should render line breaks correctly', () => {
const renderedBreaks = md.render(markdownFixtures.breaks)
expect(renderedBreaks).toMatchSnapshot()
const newmd = new Markdown({ breaks: false })
const renderedNonBreaks = newmd.render(markdownFixtures.breaks)
expect(renderedNonBreaks).toMatchSnapshot()
})
test('Markdown.render() should renders abbrevations correctly', () => {
const rendered = md.render(markdownFixtures.abbrevations)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should renders sub correctly', () => {
const rendered = md.render(markdownFixtures.subTexts)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should renders sup correctly', () => {
const rendered = md.render(markdownFixtures.supTexts)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should renders definition lists correctly', () => {
const rendered = md.render(markdownFixtures.deflists)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render shortcuts correctly', () => {
const rendered = md.render(markdownFixtures.shortcuts)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render footnote correctly', () => {
const rendered = md.render(markdownFixtures.footnote)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should renders [TOC] placholder correctly', () => {
const rendered = md.render(markdownFixtures.tocPlaceholder)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render PlantUML MindMaps correctly', () => {
const rendered = md.render(markdownFixtures.plantUmlMindMap)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render PlantUML Gantt correctly', () => {
const rendered = md.render(markdownFixtures.plantUmlGantt)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render PlantUML WBS correctly', () => {
const rendered = md.render(markdownFixtures.plantUmlWbs)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render PlantUML Umls correctly', () => {
const rendered = md.render(markdownFixtures.plantUmlUml)
expect(rendered).toMatchSnapshot()
})
test('Markdown.render() should render PlantUML Ditaa correctly', () => {
const rendered = md.render(markdownFixtures.plantUmlDitaa)
expect(rendered).toMatchSnapshot()
})