forked from skygragon/leetcode-cli
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtest_config.js
37 lines (30 loc) · 1.09 KB
/
test_config.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
var assert = require('chai').assert;
var rewire = require('rewire');
var _ = require('underscore');
describe('config', function() {
it('should ok w/o local config', function() {
var h = rewire('../lib/helper');
h.getConfigFile = function() {
return 'local-config-not-exist-at-all';
};
var config = rewire('../lib/config');
config.__set__('h', h);
config.init();
var expect = config.__get__('DEFAULT_CONFIG');
var actual = _.extendOwn({}, config); // remove 'init' function
assert.equal(_.isEqual(actual, expect), true);
});
it('should ok w/ local config', function() {
var localConfig = {LANG: 'ruby', USE_COLOR: false, AUTO_LOGIN: false};
var h = rewire('../lib/helper');
h.getFileData = function() {
return JSON.stringify(localConfig);
};
var config = rewire('../lib/config');
config.__set__('h', h);
config.init();
var expect = _.extendOwn(config.__get__('DEFAULT_CONFIG'), localConfig);
var actual = _.extendOwn({}, config); // remove 'init' function
assert.equal(_.isEqual(actual, expect), true);
});
});