-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
45 lines (36 loc) · 1.37 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
const remark = require('remark');
const joinCJKLines = require('.');
describe('remark-join-cjk-lines', () => {
const processor = remark().use(joinCJKLines);
const process = input => processor.processSync(input).toString().trim();
it('without joining', () => {
const input = ['汉字换', '行'].join('\n');
const output = remark().processSync(input).toString().trim();
expect(output).toBe(input);
});
it('should join lines', () => {
const input = ['汉字换', '行'].join('\n');
const output = process(input);
expect(output).toBe('汉字换行');
});
it('should join lines if some lines begin with spaces', () => {
const input = ['汉字换', ' 行'].join('\n');
const output = process(input);
expect(output).toBe('汉字换行');
})
it('should remove space between some punctuation', () => {
const input = ['汉字换,', '行'].join('\n');
const output = process(input)
expect(output).toBe('汉字换,行');
});
it('should keep non-linebreak space between cjk characters', () => {
const input = ['汉字 换', ' 行'].join('\n');
const output = process(input);
expect(output).toBe('汉字 换行');
});
it('should keep the space between non-cjk characters', () => {
const input = ['non-cjk', '行'].join('\n');
const output = process(input);
expect(output).toBe('non-cjk\n行');
});
});