forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (59 loc) · 1.86 KB
/
Copy pathindex.js
File metadata and controls
67 lines (59 loc) · 1.86 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
var test = require('../util/test')(__filename);
var squash = require('../../packages/string-squash');
/*
remove spaces, optionally remove escape sequences \t, \n, \f, \r and \v
squash('the cat sat on the mat'); // 'thecatsatonthemat'
squash(' the cat sat on the mat '); // 'thecatsatonthemat'
squash('\tthe cat\n sat \fon \vthe \rmat '); // '\tthecat\nsat\fon\vthe\rmat'
squash(' the \'cat\'\n sat on the mat ', true); // 'thecatsatonthemat'
squash(`the cat
sat on the mat`, true); // thecatsatonthemat
*/
test('without escapeSequence flag', function(t1) {
test('strings with no spaces are unchanged', function(t) {
t.plan(1);
var str = 'thecatsatonthemat';
var result = squash(str);
t.equal(result, 'thecatsatonthemat');
t.end();
});
test('spaces are removed', function(t) {
t.plan(1);
var str = 'the cat sat on the mat';
var result = squash(str);
t.equal(result, 'thecatsatonthemat');
t.end();
});
test('escape sequences are not removed', function(t) {
t.plan(1);
var str = '\tthe cat\n sat \fon \vthe \rmat ';
var result = squash(str);
t.equal(result, '\tthecat\nsat\fon\vthe\rmat');
t.end();
});
t1.end();
});
test('with escapeSequence flag', function(t2) {
test('strings with no escape sequences are unchanged', function(t) {
t.plan(1);
var str = 'thecatsatonthemat';
var result = squash(str, true);
t.equal(result, 'thecatsatonthemat');
t.end();
});
test('spaces are removed', function(t) {
t.plan(1);
var str = 'the cat sat on the mat';
var result = squash(str, true);
t.equal(result, 'thecatsatonthemat');
t.end();
});
test('escape sequences are removed', function(t) {
t.plan(1);
var str = '\tthe cat\n sat \fon \vthe \rmat ';
var result = squash(str, true);
t.equal(result, 'thecatsatonthemat');
t.end();
});
t2.end();
});