forked from pugjs/pug-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-file.test.js
75 lines (52 loc) · 2.49 KB
/
config-file.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var assert = require('assert');
var path = require('path');
var configFile = require('../lib/config-file');
var fixturesPath = path.join(__dirname, 'fixtures/config-file/');
describe('configFile', function () {
var config;
var reporter;
it('should load config file from specific dot file', function () {
config = configFile.load(fixturesPath + 'dotfile/.pug-lintrc');
assert.equal(config.hasOwnProperty('disallowBlockExpansion'), true, config);
});
it('should load config file from specified JavaScript file', function () {
config = configFile.load(fixturesPath + 'js/.pug-lintrc.js');
assert.equal(config.hasOwnProperty('disallowBlockExpansion'), true, config);
});
it('should load config file from specified JSON file', function () {
config = configFile.load(fixturesPath + 'json/.pug-lintrc.json');
assert.equal(config.hasOwnProperty('disallowBlockExpansion'), true, config);
});
it('should load config from dot file in working directory', function () {
config = configFile.load(null, fixturesPath + 'dotfile');
assert.equal(config.hasOwnProperty('disallowBlockExpansion'), true, config);
});
it('should load config from JSON file in working directory', function () {
config = configFile.load(null, fixturesPath + 'json');
assert.equal(config.hasOwnProperty('disallowBlockExpansion'), true, config);
});
it('should load config from package.json in working directory', function () {
config = configFile.load(null, fixturesPath + 'package');
assert.equal(config.hasOwnProperty('disallowBlockExpansion'), true, config);
});
it('should load config from home directory if working directory is empty', function () {
config = configFile.load(null, fixturesPath);
assert.equal(config === undefined, true, config);
});
it('should return in-built reporter', function () {
reporter = configFile.getReporter('console');
assert.equal(reporter.writer !== null, true, reporter);
});
it('should return custom reporter', function () {
reporter = configFile.getReporter(fixturesPath + 'reporter.js');
assert.equal(reporter.writer !== null, true, reporter);
});
it('should return null if no in-built or custom reporter is found', function () {
reporter = configFile.getReporter('nonexistent');
assert.equal(reporter.writer, null, reporter);
});
it('should return null if no reporter is specified', function () {
reporter = configFile.getReporter();
assert.equal(reporter.writer, null, reporter);
});
});