We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
shadowspawn
abetomo
tj
Learn more about funding links in repositories.
Report abuse
1 parent 4094e22 commit 1bab84cCopy full SHA for 1bab84c
tests/command.option-misuse.test.js
@@ -0,0 +1,22 @@
1
+const { Command, Option } = require('../');
2
+
3
+// It is a reasonable and easy mistake to pass Option to .option(). Detect this
4
+// and offer advice.
5
6
+const expectedMessage = 'To add an Option object use addOption() instead of option() or requiredOption()';
7
8
+test('when pass Option to .option() then throw', () => {
9
+ const program = new Command();
10
11
+ expect(() => {
12
+ program.option(new Option('-d, debug'));
13
+ }).toThrow(expectedMessage);
14
+});
15
16
+test('when pass Option to .requiredOption() then throw', () => {
17
18
19
20
+ program.requiredOption(new Option('-d, debug'));
21
22
0 commit comments