Skip to content

Commit

Permalink
Include tests for supplying optional param to .hideHelp (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn committed Oct 18, 2020
1 parent b4fbe67 commit b0c5884
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 17 additions & 1 deletion tests/command.help.test.js
Expand Up @@ -163,14 +163,30 @@ test('when no options then Options not included in helpInformation', () => {
expect(helpInformation).not.toMatch('Options');
});

test('when option hidden then option not included in helpInformation', () => {
test('when option.hideHelp() then option not included in helpInformation', () => {
const program = new commander.Command();
program
.addOption(new commander.Option('-s,--secret', 'secret option').hideHelp());
const helpInformation = program.helpInformation();
expect(helpInformation).not.toMatch('secret');
});

test('when option.hideHelp(true) then option not included in helpInformation', () => {
const program = new commander.Command();
program
.addOption(new commander.Option('-s,--secret', 'secret option').hideHelp(true));
const helpInformation = program.helpInformation();
expect(helpInformation).not.toMatch('secret');
});

test('when option.hideHelp(false) then option included in helpInformation', () => {
const program = new commander.Command();
program
.addOption(new commander.Option('-s,--secret', 'secret option').hideHelp(false));
const helpInformation = program.helpInformation();
expect(helpInformation).toMatch('secret');
});

test('when option has default value then default included in helpInformation', () => {
const program = new commander.Command();
program
Expand Down
7 changes: 4 additions & 3 deletions typings/commander-tests.ts
Expand Up @@ -264,16 +264,17 @@ const myOptionThis5: commander.Option = baseOption.makeOptionMandatory();
const myOptionThis6: commander.Option = baseOption.makeOptionMandatory(true);

// hideHelp
const myOptionThis7: commander.Option = baseOption.hideHelp();
const myOptionThis8: commander.Option = baseOption.hideHelp(true);
const hideHelpThis1: commander.Option = baseOption.hideHelp();
const hideHelpThis2: commander.Option = baseOption.hideHelp(true);
const hideHelpThis3: commander.Option = baseOption.hideHelp(false);

// argumentRejected
function goodbye(): never {
return baseOption.argumentRejected('failed');
};

// choices
const myOptionThis9: commander.Option = baseOption.choices(['a', 'b']);
const choicesThis: commander.Option = baseOption.choices(['a', 'b']);

// name
const optionName: string = baseOption.name();

0 comments on commit b0c5884

Please sign in to comment.