Skip to content

Commit 8a50ea7

Browse files
committed
Test for just flags and just description
1 parent ff301fa commit 8a50ea7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/command.helpOption.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ describe('helpOption', () => {
6868
expect(helpInformation).toMatch(/-C,--custom-help +custom help output/);
6969
});
7070

71+
test('when helpOption has just flags then helpInformation includes default description', () => {
72+
const program = new commander.Command();
73+
program
74+
.helpOption('-C,--custom-help');
75+
const helpInformation = program.helpInformation();
76+
expect(helpInformation).toMatch(/-C,--custom-help +display help for command/);
77+
});
78+
79+
test('when helpOption has just description then helpInformation includes default flags', () => {
80+
const program = new commander.Command();
81+
program
82+
.helpOption(undefined, 'custom help output');
83+
const helpInformation = program.helpInformation();
84+
expect(helpInformation).toMatch(/-h, --help +custom help output/);
85+
});
86+
7187
test('when helpOption(false) then helpInformation does not include --help', () => {
7288
const program = new commander.Command();
7389
program

0 commit comments

Comments
 (0)