Repository navigation
Expand file tree
/
Copy pathindex.test.js
More file actions
89 lines (69 loc) · 1.91 KB
/
Copy pathindex.test.js
File metadata and controls
89 lines (69 loc) · 1.91 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
const createParser = require('./index.js')
const math = require('markdown-it-math')
const markdown = `
*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium
# Heading 1
Lorem **ipsum** dolor _sit_ ++amet++ :D.
The HTML ==specification== is maintained by the W3C.
- \`item 1\`
- item 2
- item 3
Term 1
~ Definition 1
Term 2
~ Definition 2a
~ Definition 2b
\`\`\`js
function greeting() {
return 'hello world!';
}
\`\`\`
@S[soundcloud](https://soundcloud.com/platziteam/la-historia-de-platzi)
@[youtube](ajLJOhf-WdA)
[platzi](http://platzi.com/)
`
const markdownWithMath = `Pythagoran theorem is $$a^2 + b^2 = c^2$$.
Bayes theorem:
$$$
P(A | B) = (P(B | A)P(A)) / P(B)
$$$`
describe('Platzi Flavored Markdown parser', () => {
it('should work without arguments', () => {
expect(createParser()(markdown)).toMatchSnapshot()
})
it('should have link with attr noopener', () => {
const html = createParser()(markdown);
expect(html.indexOf('rel="nofollow noopener"') !== -1).toBe(true);
})
describe('Options test', () => {
it('should work with options', () => {
expect(
createParser({
html: false,
})(markdown)
).toMatchSnapshot()
})
it('should break without an object as options', () => {
expect(() => createParser('fake options')).toThrowErrorMatchingSnapshot()
})
})
describe('Extra plugins test', () => {
it('should work with extra plugins', () => {
expect(
createParser(undefined, [
math,
[
math,
{
inlineOpen: '$$',
},
],
])(markdownWithMath)
).toMatchSnapshot()
})
it('should break without an array as extra plugins', () => {
expect(() => createParser(undefined, 'fake extra plugins')).toThrowErrorMatchingSnapshot()
})
})
})