-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
42 lines (34 loc) · 958 Bytes
/
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
import test from 'ava';
import { File } from 'gulp-util';
import ellipses from 'typographic-ellipses';
import quotes from 'typographic-quotes';
import spaces from 'typographic-single-spaces';
import textr from './index';
let fixture;
test.beforeEach(() => {
fixture = new File({
path: 'fixture.txt',
contents: new Buffer(`Hello "world"...\n`)
});
});
test.cb.serial('return original text', t => {
const stream = textr();
stream.on('data', file => {
t.is(file.relative, 'fixture.txt');
t.is(file.contents.toString(), 'Hello "world"...\n');
t.end();
});
stream.write(fixture);
});
test.cb.serial('return transformed text', t => {
const stream = textr(
[ spaces, quotes, ellipses, String.prototype.trim ],
{ locale: 'en-us' }
);
stream.on('data', file => {
t.is(file.relative, 'fixture.txt');
t.is(file.contents.toString(), 'Hello “world”…');
t.end();
});
stream.write(fixture);
});