-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
68 lines (61 loc) · 1.89 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {rehype} from 'rehype'
import rehypeShiftHeading from 'rehype-shift-heading'
test('rehypeShiftHeading', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(Object.keys(await import('rehype-shift-heading')).sort(), [
'default'
])
})
await t.test('should not shift w/o `options`', async function () {
assert.equal(
String(await rehype().use(rehypeShiftHeading).process('<h2>a</h2>')),
'<html><head></head><body><h2>a</h2></body></html>'
)
})
await t.test('should not shift w/ `0`', async function () {
assert.equal(
String(
await rehype().use(rehypeShiftHeading, {shift: 0}).process('<h2>a</h2>')
),
'<html><head></head><body><h2>a</h2></body></html>'
)
})
await t.test('should shift (positive)', async function () {
assert.equal(
String(
await rehype().use(rehypeShiftHeading, {shift: 1}).process('<h2>a</h2>')
),
'<html><head></head><body><h3>a</h3></body></html>'
)
})
await t.test('should shift (negative)', async function () {
assert.equal(
String(
await rehype()
.use(rehypeShiftHeading, {shift: -1})
.process('<h2>a</h2>')
),
'<html><head></head><body><h1>a</h1></body></html>'
)
})
await t.test('should not shift past `h6`', async function () {
assert.equal(
String(
await rehype().use(rehypeShiftHeading, {shift: 6}).process('<h2>a</h2>')
),
'<html><head></head><body><h6>a</h6></body></html>'
)
})
await t.test('should not shift past `h1`', async function () {
assert.equal(
String(
await rehype()
.use(rehypeShiftHeading, {shift: -2})
.process('<h2>a</h2>')
),
'<html><head></head><body><h1>a</h1></body></html>'
)
})
})