-
Notifications
You must be signed in to change notification settings - Fork 20
/
options.tests.js
96 lines (85 loc) · 2.8 KB
/
options.tests.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* eslint-env node, mocha */
import chai from 'chai';
import packageOptionsWrapper, { reloadOptions } from './options';
import cjson from 'cjson';
import path from 'path';
import ImportPathHelpers from './helpers/import-path-helpers';
const expect = chai.expect;
cjson._load = cjson.load;
function testCjson(testFunction) {
testFunction();
cjson.load = cjson._load;
}
describe('package options', function() {
before(function() {
cjson._load = cjson.load;
cjson.test = (testFunction) => {
testFunction();
cjson.load = cjson._load;
};
});
describe('.options', function() {
it('should contain the options', function z() {
expect(packageOptionsWrapper.options.test).to.be.true;
});
});
describe('reloadOptions', function() {
it('should read package.json', function z() {
testCjson(function() {
cjson.load = (filePath) => {
expect(filePath).to.equal(path.join(ImportPathHelpers.basePath, 'package.json'));
return {};
};
reloadOptions();
});
});
it('should reload the options from package.json', function z() {
packageOptionsWrapper.options.test = false;
reloadOptions();
expect(packageOptionsWrapper.options.test).to.be.true;
});
it('should merge the default options with the options from package.json', function z() {
expect(packageOptionsWrapper.options).to.eql({
cssClassNamingConvention: {
replacements: []
},
enableProfiling: false,
enableSassCompilation: false,
enableStylusCompilation: false,
explicitIncludes: [],
extensions: ['css', 'm.css', 'mss'],
filenames: [],
globalVariablesText: '',
ignorePaths: [],
jsClassNamingConvention: {
camelCase: false
},
outputJsFilePath: '{dirname}/{basename}{extname}',
outputCssFilePath: '{dirname}/{basename}{extname}',
passthroughPaths: [],
specificArchitecture: 'web',
hash: '4ff9a143d6b0b9cc0d90193e6d55cdf6577faf70',
test: true
});
});
it('should hash the options file', function z() {
reloadOptions();
expect(packageOptionsWrapper.options.hash).to.equal('4ff9a143d6b0b9cc0d90193e6d55cdf6577faf70');
testCjson(function() {
cjson.load = (filePath) => {
expect(filePath).to.equal(path.join(ImportPathHelpers.basePath, 'package.json'));
return { test: false };
};
reloadOptions();
expect(packageOptionsWrapper.options.hash).to.equal('b70a64c10c6426233b51cf8d3162ec604c4614bc');
});
});
/**
* TODO: Tests for:
* options.cssClassNamingConvention.replacements
* options.passthroughPaths
* options.enableSassCompilation
* options.enableStylusCompilation
**/
});
});