Skip to content
Myr

command.configureHelp.test.js

This file

Path

tests/command.configureHelp.test.js

31 lines · 1.1 KiB · JavaScript

Last changed by

Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912

History of this file

Take it

Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912

lines 1–31why, one step back
1const commander = require('../');
23test('when configure program then affects program helpInformation', () => {4 const program = new commander.Command();5 program.configureHelp({ formatHelp: () => { return 'custom'; } });6 expect(program.helpInformation()).toEqual('custom');7});89test('when configure program then affects subcommand helpInformation', () => {10 const program = new commander.Command();11 program.configureHelp({ formatHelp: () => { return 'custom'; } });12 const sub = program.command('sub');13 expect(sub.helpInformation()).toEqual('custom');14});1516test('when configure with unknown property then createHelp has unknown property', () => {17 const program = new commander.Command();18 program.configureHelp({ mySecretValue: 'secret' });19 expect(program.createHelp().mySecretValue).toEqual('secret');20});2122test('when configure with unknown property then helper passed to formatHelp has unknown property', () => {23 const program = new commander.Command();24 program.configureHelp({25 mySecretValue: 'secret',26 formatHelp: (cmd, helper) => {27 return helper.mySecretValue;28 }29 });30 expect(program.helpInformation()).toEqual('secret');31});