Repository navigation
Expand file tree
/
Copy pathapi.js
More file actions
133 lines (120 loc) · 3.72 KB
/
Copy pathapi.js
File metadata and controls
133 lines (120 loc) · 3.72 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
'use strict'
var fs = require('fs')
var path = require('path')
var test = require('tape')
var alex = require('..')
var html = fs.readFileSync(path.join(__dirname, 'fixtures', 'three.html'))
// Tests. Note that these are small because alex is in fact
// just a collection of well-tested modules.
// See `retextjs/retext-equality` for the gist of what
// warnings are exposed.
test('alex()', function(t) {
t.deepEqual(
alex(
[
'The boogeyman wrote all changes to the **master server**. Thus,',
'the slaves were read-only copies of master. But not to worry,',
'he was a cripple.',
'',
'Eric is pretty set on beating your butt for sheriff.'
].join('\n')
).messages.map(String),
[
'1:5-1:14: `boogeyman` may be insensitive, use `boogeymonster` instead',
'1:42-1:48: `master` / `slaves` may be insensitive, use ' +
'`primary` / `replica` instead',
'2:5-2:11: Don’t use `slaves`, it’s profane',
'3:1-3:3: `he` may be insensitive, use `they`, `it` instead',
'3:10-3:17: `cripple` may be insensitive, use `person with a ' +
'limp` instead',
'5:36-5:40: Be careful with `butt`, it’s profane in some cases'
],
'should work'
)
t.deepEqual(
alex('Eric is pretty set on beating your butt for sheriff.', ['butt'])
.messages,
[],
'should work with an allow array'
)
t.deepEqual(
alex('Eric, the asshat, is pretty set on beating your butt for sheriff.', {
allow: ['asshat'],
profanitySureness: 1
}).messages,
[],
'should work with profantity config'
)
t.deepEqual(
alex.markdown('The `boogeyman`.').messages.map(String),
[],
'alex.markdown()'
)
t.deepEqual(
alex
.text(
[
'The `boogeyman` wrote all changes to the **master server**. Thus,',
'Eric is pretty set on beating your butt for sheriff.'
].join('\n')
)
.messages.map(String),
[
'1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead',
'2:36-2:40: Be careful with `butt`, it’s profane in some cases'
],
'alex.text()'
)
t.deepEqual(
alex
.text(
[
'The `boogeyman` wrote all changes to the **master server**. Thus,',
'Eric is pretty set on beating your butt for sheriff.'
].join('\n'),
{allow: ['butt']}
)
.messages.map(String),
['1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead'],
'alex.text() with allow config'
)
t.deepEqual(
alex
.text(
[
'The `boogeyman` wrote all changes to the **master server**. Thus,',
'Eric is pretty set on beating your butt for sheriff.'
].join('\n'),
['butt']
)
.messages.map(String),
['1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead'],
'alex.text() with allow array'
)
t.deepEqual(
alex.html(html).messages.map(String),
[
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead',
'11:36-11:40: Be careful with `butt`, it’s profane in some cases'
],
'alex.html()'
)
t.deepEqual(
alex.html(html, {allow: ['butt']}).messages.map(String),
[
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead'
],
'alex.html() with allow config'
)
t.deepEqual(
alex.html(html, ['butt']).messages.map(String),
[
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead'
],
'alex.html() with allow array'
)
t.end()
})