help.commandTerm.test.js
This file
Path
tests/help.commandTerm.test.js
42 lines · 1.7 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 2911e0e point at it.
docs: update SECURITY.mdabetomobefore adoption2911e0e
lines 1–14why, 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).56// subcommandTerm does not currently respect helpOption or ignore hidden options, so not testing those.7describe('subcommandTerm', () => {8 test('when plain command then returns name', () => {9 const command = new commander.Command('program');10 const helper = new commander.Help();11 expect(helper.subcommandTerm(command)).toEqual('program');12 });1314 test('when command has alias then returns name|alias', () => {Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 15why, one step back15 const command = new commander.Command('program').alias('alias');docs: update SECURITY.mdabetomobefore adoption2911e0e
lines 16–20why, one step back16 const helper = new commander.Help();17 expect(helper.subcommandTerm(command)).toEqual('program|alias');18 });1920 test('when command has options then returns name [options]', () => {Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 21why, one step back21 const command = new commander.Command('program').option('-a,--all');docs: update SECURITY.mdabetomobefore adoption2911e0e
lines 22–26why, one step back22 const helper = new commander.Help();23 expect(helper.subcommandTerm(command)).toEqual('program [options]');24 });2526 test('when command has <argument> then returns name <argument>', () => {Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 27why, one step back27 const command = new commander.Command('program').argument('<argument>');docs: update SECURITY.mdabetomobefore adoption2911e0e
lines 28–37why, one step back28 const helper = new commander.Help();29 expect(helper.subcommandTerm(command)).toEqual('program <argument>');30 });3132 test('when command has everything then returns name|alias [options] <argument>', () => {33 const command = new commander.Command('program')34 .alias('alias')35 .option('-a,--all')36 .argument('<argument>');37 const helper = new commander.Help();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 38–40why, one step back38 expect(helper.subcommandTerm(command)).toEqual(39 'program|alias [options] <argument>',40 );docs: update SECURITY.mdabetomobefore adoption2911e0e
lines 41–42why, one step back41 });42});