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

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

The walk stopped after 200 commits: lines older than 471ec40 point at it.

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

lines 1–3why, one step back
1import * as commander from '../index.js';
2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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