help.padWidth.test.js
This file
Path
tests/help.padWidth.test.js
55 lines · 1.9 KiB · JavaScript
Last changed by
Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
History of this fileTake it
Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912
lines 1–10why, one step back1const commander = require('../');23// These are tests of the Help class, not of the Command help.4// There is some overlap with the higher level Command tests (which predate Help).56describe('padWidth', () => {7 test('when argument term longest return argument length', () => {8 const longestThing = 'veryLongThingBiggerThanOthers';9 const program = new commander.Command();10 programMore consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9
line 11why, one step back11 .argument(`<${longestThing}>`, 'description')Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912
lines 12–22why, one step back12 .option('-o');13 program14 .command('sub');15 const helper = new commander.Help();16 expect(helper.padWidth(program, helper)).toEqual(longestThing.length);17 });1819 test('when option term longest return option length', () => {20 const longestThing = '--very-long-thing-bigger-than-others';21 const program = new commander.Command();22 programMore consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9
line 23why, one step back23 .argument('<file>', 'desc')Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912
lines 24–30why, one step back24 .option(longestThing);25 program26 .command('sub');27 const helper = new commander.Help();28 expect(helper.padWidth(program, helper)).toEqual(longestThing.length);29 });30Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
lines 31–43why, one step back31 test('when global option term longest return global option length', () => {32 const longestThing = '--very-long-thing-bigger-than-others';33 const program = new commander.Command();34 program35 .argument('<file>', 'desc')36 .option(longestThing)37 .configureHelp({ showGlobalOptions: true });38 const sub = program39 .command('sub');40 const helper = sub.createHelp();41 expect(helper.padWidth(sub, helper)).toEqual(longestThing.length);42 });43Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912
lines 44–47why, one step back44 test('when command term longest return command length', () => {45 const longestThing = 'very-long-thing-bigger-than-others';46 const program = new commander.Command();47 programMore consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9
line 48why, one step back48 .argument('<file>', 'desc')Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912
lines 49–55why, one step back49 .option('-o');50 program51 .command(longestThing);52 const helper = new commander.Help();53 expect(helper.padWidth(program, helper)).toEqual(longestThing.length);54 });55});