-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/argument arg explicit (#1567)
* Add new methods * Add chain test * Add tests for Argument.required * Add typings for argRequired and argOptional
- Loading branch information
1 parent
4be69f1
commit 6f51e4a
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters