Skip to content
Myr

Test coverage (#1433)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Test for just flags and just description * Edge case test for wrap with trivial input * Add obscure edge case for coverage * Add test for variadic argument usage/help * Suppress tests that uncredited coverage and not currently chasing * Revert "Suppress tests that uncredited coverage and not currently chasing" This reverts commit d3c91462504b94c283bee6110ebc8908433d876c.

authored by John Gee · committed by GitHub · parent ff301fa · Browse files · 4 files+43 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+43 added−1 removed

  • tests:+43 added−1 removed

4 files+43 added−1 removed

modified:tests/args.variadic.test.js+9 added
modified:tests/command.helpOption.test.js+16 added
66 unmodified lines
67 const helpInformation = program.helpInformation();68 expect(helpInformation).toMatch(/-C,--custom-help +custom help output/);69 });7071 test('when helpOption has just flags then helpInformation includes default description', () => {72 const program = new commander.Command();73 program74 .helpOption('-C,--custom-help');75 const helpInformation = program.helpInformation();76 expect(helpInformation).toMatch(/-C,--custom-help +display help for command/);77 });7879 test('when helpOption has just description then helpInformation includes default flags', () => {80 const program = new commander.Command();81 program82 .helpOption(undefined, 'custom help output');83 const helpInformation = program.helpInformation();84 expect(helpInformation).toMatch(/-h, --help +custom help output/);85 });8687 test('when helpOption(false) then helpInformation does not include --help', () => {88 const program = new commander.Command();89 program90 .helpOption(false);
43 unmodified lines
modified:tests/help.wrap.test.js+8 added-1 removed
2 unmodified lines
3// These are tests of the Help class, not of the Command help.4// There is some overlap with the higher level Command tests (which predate Help).56describe('wrap', () => {7 test('when string fits into width then no wrap', () => {7 test('when string fits into width then returns input', () => {8 const text = 'a '.repeat(24) + 'a';9 const helper = new commander.Help();10 const wrapped = helper.wrap(text, 50, 3);11 expect(wrapped).toEqual(text);12 });1314 test('when string shorter than indent then returns input', () => {15 const text = 'a';16 const helper = new commander.Help();17 const wrapped = helper.wrap(text, 50, 3);18 expect(wrapped).toEqual(text);19 });2021 test('when string exceeds width then wrap', () => {22 const text = 'a '.repeat(30) + 'a';23 const helper = new commander.Help();24 const wrapped = helper.wrap(text, 50, 0);
147 unmodified lines
modified:tests/options.bool.test.js+10 added
104 unmodified lines
105 .option('-v, --olives', 'Add olives? Sorry we only have black.', flagValue);106 program.parse(['node', 'test', '--olives']);107 expect(program.opts().olives).toBe(flagValue);108 });109110 test('when flag implied and negated then value is false', () => {111 const flagValue = 'black';112 const program = new commander.Command();113 program114 .option('-v, --olives', 'Add olives? Sorry we only have black.', flagValue)115 .option('--no-olives');116 program.parse(['node', 'test', '--olives', '--no-olives']);117 expect(program.opts().olives).toBe(false);118 });119});120121// Regression test for #1301 with `-no-` in middle of option122describe('regression test for -no- in middle of option flag', () => {
16 unmodified lines