command.addHelpOption.test.js
This file
Path
tests/command.addHelpOption.test.js
41 lines · 1.3 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142import { Option } from '../index.js';import { createTestCommand } from './testHelpers.js';import { test, describe } from 'node:test';import assert from 'node:assert/strict';
// More complete tests are in command.helpOption.test.js.
describe('Command.addHelpOption()', () => { test('when addHelpOption has custom flags then custom short flag invokes help', () => { const program = createTestCommand(); program.addHelpOption(new Option('-c,--custom-help'));
assert.throws( () => { program.parse(['-c'], { from: 'user' }); }, { message: '(outputHelp)' }, ); });
test('when addHelpOption has custom flags then custom long flag invokes help', () => { const program = createTestCommand(); program.addHelpOption(new Option('-c,--custom-help'));
assert.throws( () => { program.parse(['--custom-help'], { from: 'user' }); }, { message: '(outputHelp)' }, ); });
test('when addHelpOption with hidden help option then help does not include help option', () => { const program = createTestCommand(); program.addHelpOption( new Option('-c,--custom-help', 'help help help').hideHelp(), ); const helpInfo = program.helpInformation(); assert.doesNotMatch(helpInfo, /help/); });});