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

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 0b0fbbe point at it.

Update dependencies (#1524)John Geebefore adoption0b0fbbe

lines 1–43why, 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')30 .argument('<argument>');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')39 .argument('<argument>');40 const helper = new commander.Help();41 expect(helper.subcommandTerm(command)).toEqual('program|alias [options] <argument>');42 });43});