-
-
Notifications
You must be signed in to change notification settings - Fork 436
/
Copy pathcli-config.test.ts
44 lines (39 loc) · 1.41 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
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();
(conf.daemon as any).port = String(conf.daemon.port);
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: []
},
daemon: {
port: 5000
},
directories: {
data: 'data',
downloads: 'downloads',
user: 'user'
}
}
}
});