-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
argument.required.test.js
34 lines (28 loc) · 1.11 KB
/
argument.required.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
const commander = require('../');
// Low-level tests of setting Argument.required.
// Higher level tests of optional/required arguments elsewhere.
test('when name with surrounding <> then argument required', () => {
const argument = new commander.Argument('<name>');
expect(argument.required).toBe(true);
});
test('when name with surrounding [] then argument optional', () => {
const argument = new commander.Argument('[name]');
expect(argument.required).toBe(false);
});
test('when name without surrounding brackets then argument required', () => {
// default behaviour, allowed from Commander 8
const argument = new commander.Argument('name');
expect(argument.required).toBe(true);
});
test('when call .argRequired() then argument required', () => {
const argument = new commander.Argument('name');
argument.required = false;
argument.argRequired();
expect(argument.required).toBe(true);
});
test('when call .argOptional() then argument optional', () => {
const argument = new commander.Argument('name');
argument.required = true;
argument.argOptional();
expect(argument.required).toBe(false);
});