-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
62 lines (56 loc) · 1.48 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
const remark = require("remark");
const stringify = require("remark-rehype");
const html = require("rehype-stringify");
const autoHeadingId = require(".");
describe("autoHeadingId", function () {
it("should parse with id", function () {
let { contents } = remark()
.data("settings", {
position: false,
})
.use(autoHeadingId)
.use(stringify)
.use(html).processSync(`
# heading one
## heading two
`);
expect(contents).toMatchInlineSnapshot(`
"<h1 id=\\"id1\\">heading one</h1>
<h2 id=\\"id2\\">heading two</h2>"
`);
});
it("should parse with custom prefix", function () {
let { contents } = remark()
.data("settings", {
position: false,
})
.use(autoHeadingId, { prefix: "heading-" })
.use(stringify)
.use(html).processSync(`
# heading one
## heading two
`);
expect(contents).toMatchInlineSnapshot(`
"<h1 id=\\"heading-1\\">heading one</h1>
<h2 id=\\"heading-2\\">heading two</h2>"
`);
});
it("should parse with custom id", function () {
let { contents } = remark()
.data("settings", {
position: false,
})
.use(autoHeadingId)
.use(stringify)
.use(html).processSync(`
# heading one
## heading two {#custom-id}
## heading three
`);
expect(contents).toMatchInlineSnapshot(`
"<h1 id=\\"id1\\">heading one</h1>
<h2 id=\\"custom-id\\">heading two</h2>
<h2 id=\\"id2\\">heading three</h2>"
`);
});
});