-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
56 lines (50 loc) · 1.67 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {retext} from 'retext'
import retextPassive from 'retext-passive'
test('retext-passive', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(Object.keys(await import('retext-passive')).sort(), [
'default'
])
})
const doc = 'He was withheld while we were being fed.\nFed.\nThe fed.'
const file = await retext().use(retextPassive).process(doc)
await t.test('should emit a message w/ metadata', async function () {
assert.deepEqual(
JSON.parse(JSON.stringify({...file.messages[0], ancestors: []})),
{
ancestors: [],
column: 8,
fatal: false,
message: 'Unexpected use of the passive voice',
line: 1,
name: '1:8-1:16',
place: {
start: {line: 1, column: 8, offset: 7},
end: {line: 1, column: 16, offset: 15}
},
reason: 'Unexpected use of the passive voice',
ruleId: 'withheld',
source: 'retext-passive',
actual: 'withheld',
expected: [],
url: 'https://github.com/retextjs/retext-passive#readme'
}
)
})
await t.test('should emit messasges', async function () {
assert.deepEqual(file.messages.map(String), [
'1:8-1:16: Unexpected use of the passive voice',
'1:37-1:40: Unexpected use of the passive voice'
])
})
await t.test('should `ignore`', async function () {
const file = await retext()
.use(retextPassive, {ignore: ['fed']})
.process(doc)
assert.deepEqual(file.messages.map(String), [
'1:8-1:16: Unexpected use of the passive voice'
])
})
})