command.configureHelp.test.js
This file
Path
tests/command.configureHelp.test.js
43 lines · 1.4 KiB · JavaScript
Last changed by
Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344const commander = require('../');const { test, describe } = require('node:test');const assert = require('node:assert/strict');
describe('Command.configureHelp()', () => { test('when configure program then affects program helpInformation', () => { const program = new commander.Command(); program.configureHelp({ formatHelp: () => { return 'custom'; }, }); assert.equal(program.helpInformation(), 'custom'); });
test('when configure program then affects subcommand helpInformation', () => { const program = new commander.Command(); program.configureHelp({ formatHelp: () => { return 'custom'; }, }); const sub = program.command('sub'); assert.equal(sub.helpInformation(), 'custom'); });
test('when configure with unknown property then createHelp has unknown property', () => { const program = new commander.Command(); program.configureHelp({ mySecretValue: 'secret' }); assert.equal(program.createHelp().mySecretValue, '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; }, }); assert.equal(program.helpInformation(), 'secret'); });});