-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
64 lines (55 loc) · 1.79 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {fromMarkdown} from 'mdast-util-from-markdown'
import {u} from 'unist-builder'
import {removePosition} from 'unist-util-remove-position'
test('removePosition', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(
Object.keys(await import('unist-util-remove-position')).sort(),
['removePosition']
)
})
await t.test('should work softly', async function () {
const empty = {position: undefined}
const root = fromMarkdown('Some **strong**, _emphasis_, and `code`.')
removePosition(root)
assert.deepEqual(
root,
u('root', empty, [
u('paragraph', empty, [
u('text', empty, 'Some '),
u('strong', empty, [u('text', empty, 'strong')]),
u('text', empty, ', '),
u('emphasis', empty, [u('text', empty, 'emphasis')]),
u('text', empty, ', and '),
u('inlineCode', empty, 'code'),
u('text', empty, '.')
])
])
)
})
await t.test('should work by force', async function () {
const root = fromMarkdown('Some **strong**, _emphasis_, and `code`.')
removePosition(root, {force: true})
assert.deepEqual(
root,
u('root', [
u('paragraph', [
u('text', 'Some '),
u('strong', [u('text', 'strong')]),
u('text', ', '),
u('emphasis', [u('text', 'emphasis')]),
u('text', ', and '),
u('inlineCode', 'code'),
u('text', '.')
])
])
)
})
await t.test('should support options', async function () {
const root = fromMarkdown('x')
removePosition(root, {force: true})
assert.deepEqual(root, u('root', [u('paragraph', [u('text', 'x')])]))
})
})