help.commandUsage.test.js
This file
Path
tests/help.commandUsage.test.js
45 lines · 1.7 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake 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 back1import * 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–7why, one step back45// 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).7Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 8why, one step back8describe('Help.commandUsage()', () => {Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 9–12why, one step back9 test('when single program then "program [options]"', () => {10 const program = new commander.Command();11 program.name('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 back13 assert.equal(helper.commandUsage(program), 'program [options]');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 14–20why, one step back14 });1516 test('when multi program then "program [options] [command]"', () => {17 const program = new commander.Command();18 program.name('program');19 program.command('sub');20 const helper = new commander.Help();Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 21why, one step back21 assert.equal(helper.commandUsage(program), 'program [options] [command]');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 22–25why, one step back22 });2324 test('when program has alias then usage includes alias', () => {25 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 26why, one step back26 program.name('program').alias('alias');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 27why, one step back27 const helper = new commander.Help();Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 28why, one step back28 assert.equal(helper.commandUsage(program), 'program|alias [options]');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 29–32why, one step back29 });3031 test('when help for subcommand then usage includes hierarchy', () => {32 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 33–34why, one step back33 program.name('program');34 const sub = program.command('sub').name('sub');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 35why, one step back35 const helper = new commander.Help();Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 36why, one step back36 assert.equal(helper.commandUsage(sub), 'program sub [options]');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 37–40why, one step back37 });3839 test('when program has argument then usage includes argument', () => {40 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 41why, one step back41 program.name('program').argument('<file>');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 42why, one step back42 const helper = new commander.Help();Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 43why, one step back43 assert.equal(helper.commandUsage(program), 'program [options] <file>');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 44–45why, one step back44 });45});