Skip to content
Myr

help.commandTerm.test.js

This file

Path

tests/help.commandTerm.test.js

43 lines · 1.7 KiB · JavaScript

Last changed by

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

History of this file

Take it

The walk stopped after 200 commits: lines older than 20cef03 point at it.

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 1–29why, one step back
1const 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', () => {15 const command = new commander.Command('program')16 .alias('alias');17 const helper = new commander.Help();18 expect(helper.subcommandTerm(command)).toEqual('program|alias');19 });2021 test('when command has options then returns name [options]', () => {22 const command = new commander.Command('program')23 .option('-a,--all');24 const helper = new commander.Help();25 expect(helper.subcommandTerm(command)).toEqual('program [options]');26 });2728 test('when command has <argument> then returns name <argument>', () => {29 const command = new commander.Command('program')

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

line 30why, one step back
30 .argument('<argument>');

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 31–38why, one step back
31 const helper = new commander.Help();
32 expect(helper.subcommandTerm(command)).toEqual('program <argument>');33 });3435 test('when command has everything then returns name|alias [options] <argument>', () => {36 const command = new commander.Command('program')37 .alias('alias')38 .option('-a,--all')

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

line 39why, one step back
39 .argument('<argument>');

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 40–43why, one step back
40 const helper = new commander.Help();
41 expect(helper.subcommandTerm(command)).toEqual('program|alias [options] <argument>');42 });43});