-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
48 lines (44 loc) · 1.6 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {retext} from 'retext'
import retextDiacritics from 'retext-diacritics'
test('retext-diacritics', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(Object.keys(await import('retext-diacritics')).sort(), [
'default'
])
})
const file = await retext()
.use(retextDiacritics)
.process('Beyonce is the creme fresh on his resume.')
await t.test('should emit messages', async function () {
assert.deepEqual(file.messages.map(String), [
'1:1-1:8: Unexpected undiacritical `Beyonce`, did you mean `Beyoncé`',
'1:16-1:27: Unexpected undiacritical `creme fresh`, did you mean `crème fraîche`',
'1:31-1:41: Unexpected undiacritical `his resume`, did you mean `his résumé`'
])
})
await t.test('should emit a message w/ metadata', async function () {
assert.deepEqual(
JSON.parse(JSON.stringify({...file.messages[0], ancestors: []})),
{
ancestors: [],
column: 1,
fatal: false,
message: 'Unexpected undiacritical `Beyonce`, did you mean `Beyoncé`',
line: 1,
name: '1:1-1:8',
place: {
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 8, offset: 7}
},
reason: 'Unexpected undiacritical `Beyonce`, did you mean `Beyoncé`',
ruleId: 'beyonce',
source: 'retext-diacritics',
actual: 'Beyonce',
expected: ['Beyoncé'],
url: 'https://github.com/retext/retext-diacritics#readme'
}
)
})
})