-
-
Notifications
You must be signed in to change notification settings - Fork 439
/
Copy pathcli-config.test.ts
49 lines (46 loc) · 1.24 KB
/
cli-config.test.ts
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
import { expect } from 'chai';
import { DefaultCliConfig } from '../../node/cli-config';
describe('cli-config', () => {
type ConfigProvider = DefaultCliConfig | { (): DefaultCliConfig };
(
[
[defaultConfig, defaultConfig, true],
[
() => {
const conf = defaultConfig();
delete conf.board_manager;
return conf;
},
defaultConfig,
true,
],
[
() => {
const conf = defaultConfig();
return conf;
},
defaultConfig,
true,
],
] as [ConfigProvider, ConfigProvider, boolean][]
).forEach(([leftInput, rightInput, expectation]) => {
const left = typeof leftInput === 'function' ? leftInput() : leftInput;
const right = typeof rightInput === 'function' ? rightInput() : rightInput;
it(`${JSON.stringify(left)} should ${
expectation ? '' : 'not '
}be the same as ${JSON.stringify(right)}`, () => {
expect(DefaultCliConfig.sameAs(left, right)).to.be.equal(expectation);
});
});
function defaultConfig(): DefaultCliConfig {
return {
board_manager: {
additional_urls: [],
},
directories: {
data: 'data',
user: 'user',
},
};
}
});