-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick fixes to handle CLI args errors (#306)
* add cli-action-error-empty-args-missing-name.test.js demonstrates correct behavior in this case * add cli-action-error-undefined-args-missing-name.test.js reproduces issue 305 in lib/cli-command.js * add cli-action-error-too-many-args.test.js which fails at this point, reproducing issue 119 (extra arguments silently ignored) * throw error in case of too many arguments (issue 119) * throw explicit error in case of missing args with name (issue 305)
- Loading branch information
Showing
4 changed files
with
33 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
7 changes: 7 additions & 0 deletions
7
.../with-injection/cli/command/action-error/cli-action-error-empty-args-missing-name.test.js
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,7 @@ | ||
const action = require('../../../../../lib/cli-command.js').action; | ||
|
||
test('create lib module with empty args - missing name', () => { | ||
const args = []; | ||
|
||
expect(() => { action(args, {}); }).toThrow('missing lib module name'); | ||
}); |
9 changes: 9 additions & 0 deletions
9
tests/with-injection/cli/command/action-error/cli-action-error-too-many-args.test.js
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,9 @@ | ||
const action = require('../../../../../lib/cli-command.js').action; | ||
|
||
test('create module with too many args', () => { | ||
const args = ['name1', 'name2']; | ||
|
||
// ref: | ||
// https://github.com/brodybits/create-react-native-module/issues/119 | ||
expect(() => { action(args, {}); }).toThrow('too many arguments'); | ||
}); |
9 changes: 9 additions & 0 deletions
9
...h-injection/cli/command/action-error/cli-action-error-undefined-args-missing-name.test.js
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,9 @@ | ||
const action = require('../../../../../lib/cli-command.js').action; | ||
|
||
test('create lib module with undefined args - missing name', () => { | ||
const args = undefined; | ||
|
||
// ref: | ||
// https://github.com/brodybits/create-react-native-module/issues/305 | ||
expect(() => { action(args, {}); }).toThrow('missing lib module name'); | ||
}); |