command.configureHelp.test.js
This file
Path
tests/command.configureHelp.test.js
39 lines · 1.2 KiB · JavaScript
Last changed by
Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637383940const commander = require('../');
test('when configure program then affects program helpInformation', () => { const program = new commander.Command(); program.configureHelp({ formatHelp: () => { return 'custom'; }, }); expect(program.helpInformation()).toEqual('custom');});
test('when configure program then affects subcommand helpInformation', () => { const program = new commander.Command(); program.configureHelp({ formatHelp: () => { return 'custom'; }, }); const sub = program.command('sub'); expect(sub.helpInformation()).toEqual('custom');});
test('when configure with unknown property then createHelp has unknown property', () => { const program = new commander.Command(); program.configureHelp({ mySecretValue: 'secret' }); expect(program.createHelp().mySecretValue).toEqual('secret');});
test('when configure with unknown property then helper passed to formatHelp has unknown property', () => { const program = new commander.Command(); program.configureHelp({ mySecretValue: 'secret', formatHelp: (cmd, helper) => { return helper.mySecretValue; }, }); expect(program.helpInformation()).toEqual('secret');});