forked from tj/commander.js
/
option.chain.test.js
39 lines (33 loc) · 1.25 KB
/
option.chain.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
const { Option } = require('../');
describe('Option methods that should return this for chaining', () => {
test('when call .default() then returns this', () => {
const option = new Option('-e,--example <value>');
const result = option.default(3);
expect(result).toBe(option);
});
test('when call .argParser() then returns this', () => {
const option = new Option('-e,--example <value>');
const result = option.argParser(() => { });
expect(result).toBe(option);
});
test('when call .makeOptionMandatory() then returns this', () => {
const option = new Option('-e,--example <value>');
const result = option.makeOptionMandatory();
expect(result).toBe(option);
});
test('when call .hideHelp() then returns this', () => {
const option = new Option('-e,--example <value>');
const result = option.hideHelp();
expect(result).toBe(option);
});
test('when call .choices() then returns this', () => {
const option = new Option('-e,--example <value>');
const result = option.choices(['a']);
expect(result).toBe(option);
});
test('when call .env() then returns this', () => {
const option = new Option('-e,--example <value>');
const result = option.env('e');
expect(result).toBe(option);
});
});