Skip to content
Myr

help.commandTerm.test.js

This file

Path

tests/help.commandTerm.test.js

45 lines · 1.8 KiB · JavaScript

Last changed by

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

History of this file

Take it

The walk stopped after 200 commits: lines older than 3103c6b point at it.

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 1why, one step back
1const commander = require('../');

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 2–3why, one step back
2const { test, describe } = require('node:test');
3const assert = require('node:assert/strict');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 4–8why, one step back
4
5// These are tests of the Help class, not of the Command help.6// There is some overlap with the higher level Command tests (which predate Help).78// subcommandTerm does not currently respect helpOption or ignore hidden options, so not testing those.

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

line 9why, one step back
9describe('Help.subcommandTerm()', () => {

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 10–12why, one step back
10 test('when plain command then returns name', () => {
11 const command = new commander.Command('program');12 const helper = new commander.Help();

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 13why, one step back
13 assert.equal(helper.subcommandTerm(command), 'program');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 14–16why, one step back
14 });
1516 test('when command has alias then returns name|alias', () => {

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 17why, one step back
17 const command = new commander.Command('program').alias('alias');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 18why, one step back
18 const helper = new commander.Help();

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 19why, one step back
19 assert.equal(helper.subcommandTerm(command), 'program|alias');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 20–22why, one step back
20 });
2122 test('when command has options then returns name [options]', () => {

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 23why, one step back
23 const command = new commander.Command('program').option('-a,--all');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 24why, one step back
24 const helper = new commander.Help();

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 25why, one step back
25 assert.equal(helper.subcommandTerm(command), 'program [options]');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 26–28why, one step back
26 });
2728 test('when command has <argument> then returns name <argument>', () => {

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 29why, one step back
29 const command = new commander.Command('program').argument('<argument>');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 30why, one step back
30 const helper = new commander.Help();

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 31why, one step back
31 assert.equal(helper.subcommandTerm(command), 'program <argument>');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

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

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 40–41why, one step back
40 assert.equal(
41 helper.subcommandTerm(command),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 42–43why, one step back
42 'program|alias [options] <argument>',
43 );

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 44–45why, one step back
44 });
45});