help.commandUsage.test.js
This file
Path
tests/help.commandUsage.test.js
43 lines · 1.6 KiB · JavaScript
Last changed by
Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
History of this fileTake it
The walk stopped after 200 commits: lines older than 36c2f68 point at it.
Change .action() JSDoc/TSDoc example (#1614)John Geebefore adoption36c2f68
lines 1–23why, 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('commandUsage', () => {7 test('when single program then "program [options]"', () => {8 const program = new commander.Command();9 program.name('program');10 const helper = new commander.Help();11 expect(helper.commandUsage(program)).toEqual('program [options]');12 });1314 test('when multi program then "program [options] [command]"', () => {15 const program = new commander.Command();16 program.name('program');17 program.command('sub');18 const helper = new commander.Help();19 expect(helper.commandUsage(program)).toEqual('program [options] [command]');20 });2122 test('when program has alias then usage includes alias', () => {23 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 24why, one step back24 program.name('program').alias('alias');Change .action() JSDoc/TSDoc example (#1614)John Geebefore adoption36c2f68
lines 25–30why, one step back25 const helper = new commander.Help();26 expect(helper.commandUsage(program)).toEqual('program|alias [options]');27 });2829 test('when help for subcommand then usage includes hierarchy', () => {30 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 31–32why, one step back31 program.name('program');32 const sub = program.command('sub').name('sub');Change .action() JSDoc/TSDoc example (#1614)John Geebefore adoption36c2f68
lines 33–38why, one step back33 const helper = new commander.Help();34 expect(helper.commandUsage(sub)).toEqual('program sub [options]');35 });3637 test('when program has argument then usage includes argument', () => {38 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 39why, one step back39 program.name('program').argument('<file>');Change .action() JSDoc/TSDoc example (#1614)John Geebefore adoption36c2f68
lines 40–43why, one step back40 const helper = new commander.Help();41 expect(helper.commandUsage(program)).toEqual('program [options] <file>');42 });43});