forked from apidoc/apidoc-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_unindent_test.js
52 lines (40 loc) · 1.33 KB
/
util_unindent_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
/*jshint unused:false*/
/**
* Test: Util unindent
*/
// node modules
var should = require('should');
// lib modules
var unindent = require('../lib/utils/unindent');
describe('Util: unindent', function() {
it('should strip common leading spaces', function(done) {
unindent(' a\n b\n c').should.equal('a\n b\n c');
done();
});
it('should strip common leading tabs', function(done) {
unindent('\t\ta\n\t\t\t\tb\n\t\t\tc').should.equal('a\n\t\tb\n\tc');
done();
});
it('should strip all leading whitespace from a single line', function(done) {
unindent(' \t a').should.equal('a');
done();
});
it('should not modify the empty string', function(done) {
var s = '';
unindent(s).should.equal(s);
done();
});
it('should not modify if any line starts with non-whitespace', function(done) {
var s = ' a\n b\nc d\n e';
unindent(s).should.equal(s);
done();
});
it('should strip common leading tabs and keep spaces', function(done) {
unindent('\ta\n\t b\n\t c').should.equal('a\n b\n c');
done();
});
it('should strip common leading tabs and 1 space on each line', function(done) {
unindent('\t a\n\t b\n\t c').should.equal(' a\n b\nc');
done();
});
});