forked from retextjs/retext-simplify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
60 lines (53 loc) · 1.5 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
/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module retext:intensify
* @fileoverview Test suite for `retext-simplify`.
*/
'use strict';
/* Dependencies. */
var test = require('tape');
var retext = require('retext');
var simplify = require('./');
/* Tests. */
test('simplify', function (t) {
t.plan(4);
retext()
.use(simplify)
.process([
'You can utilize a shorter word.',
'Be advised, don’t do this.',
'That’s the appropriate thing to do.'
].join('\n'), function (err, file) {
t.ifError(err, 'should not fail (#1)');
t.deepEqual(
file.messages.map(String),
[
'1:9-1:16: Replace “utilize” with “use”',
'2:1-2:11: Remove “Be advised”',
'3:12-3:23: Replace “appropriate” with “proper”, ' +
'“right”, or remove it'
],
'should warn about simpler synonyms'
);
});
retext()
.use(simplify, {ignore: ['utilize']})
.process([
'You can utilize a shorter word.',
'Be advised, don’t do this.',
'That’s the appropriate thing to do.'
].join('\n'), function (err, file) {
t.ifError(err, 'should not fail (#2)');
t.deepEqual(
file.messages.map(String),
[
'2:1-2:11: Remove “Be advised”',
'3:12-3:23: Replace “appropriate” with “proper”, ' +
'“right”, or remove it'
],
'should not warn for `ignore`d phrases'
);
});
});