forked from remarkjs/remark-yaml-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
78 lines (71 loc) · 1.71 KB
/
test.js
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
import test from 'tape'
import {unified} from 'unified'
import {remark} from 'remark'
import remarkFrontmatter from 'remark-frontmatter'
import remarkHtml from 'remark-html'
import remarkYamlConfig from './index.js'
test('remark-yaml-config', (t) => {
t.equal(
remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.processSync('# Foo bar\n')
.toString(),
'# Foo bar\n',
'should not fail without yaml'
)
t.equal(
remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.processSync('---\n---')
.toString(),
'---\n---\n',
'should not fail on empty yaml'
)
t.equal(
remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.processSync('---\nremark:\n bullet: "*"\n---\n- Foo')
.toString(),
'---\nremark:\n bullet: "*"\n---\n\n* Foo\n',
'should set stringification options'
)
t.throws(
() => {
remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.processSync('---\nremark:\n bullet: "?"\n---\n- Foo')
.toString()
},
/Cannot serialize items with `\?` for `options.bullet`/,
'should throw exceptions'
)
t.doesNotThrow(() => {
unified().use(remarkYamlConfig).freeze()
}, 'should not throw without compiler')
t.equal(
remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.use(remarkHtml)
.processSync(
[
'---',
'remark:',
' commonmark: true',
' bullet: "*"',
'---',
'',
'1. Foo',
''
].join('\n')
)
.toString(),
'<ol>\n<li>Foo</li>\n</ol>\n',
'should work with a different compiler'
)
t.end()
})