command.addHelpOption.test.js
This file
Path
tests/command.addHelpOption.test.js
41 lines · 1.3 KiB · JavaScript
Last changed by
Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142const { Option } = require('../');const { createTestCommand } = require('./testHelpers');const { test, describe } = require('node:test');const assert = require('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/); });});