-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
37 lines (35 loc) · 785 Bytes
/
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
import test from 'ava';
import {unified} from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import remarkCustomHeaderId from './index.js';
test('main', async t => {
const file = await unified()
.use(remarkParse)
.use(remarkCustomHeaderId)
.use(remarkRehype)
.use(rehypeStringify)
.process(`
# unicorn {#foo-bar}
# a {#aa}
# b
## c {#foo bar}
# unicorn ||foo-bar||
# a ||aa||
## c ||foo bar||
# d {#wrong id||
# e ||wrong id}
`.trim());
t.is(file.value, `
<h1 id="foo-bar">unicorn</h1>
<h1 id="aa">a</h1>
<h1>b</h1>
<h2 id="foo bar">c</h2>
<h1 id="foo-bar">unicorn</h1>
<h1 id="aa">a</h1>
<h2 id="foo bar">c</h2>
<h1>d {#wrong id||</h1>
<h1>e ||wrong id}</h1>
`.trim());
});