forked from sindresorhus/detect-indent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
33 lines (26 loc) · 1.07 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
'use strict';
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var detectIndent = require('./');
function getFile(file) {
return fs.readFileSync(path.join(__dirname, file), 'utf8');
}
it('should detect the indent of a file with space indent', function () {
assert.equal(detectIndent(getFile('fixture/space.js')), ' ');
});
it('should detect the indent of a file with tab indent', function () {
assert.equal(detectIndent(getFile('fixture/tab.js')), '\t');
});
it('should detect the indent of a file with mostly tabs', function () {
assert.equal(detectIndent(getFile('fixture/mixed-tab.js')), '\t');
});
it('should detect the indent of a file with mostly spaces', function () {
assert.equal(detectIndent(getFile('fixture/mixed-space.js')), ' ');
});
it('should detect the indent of a weirdly indented vendor prefixed CSS', function () {
assert.equal(detectIndent(getFile('fixture/vendor-prefixed-css.css')), ' ');
});
it('should return `null` when there are no indentation', function () {
assert.equal(detectIndent('<ul></ul>'), null);
});