Skip to content
Myr

help.visibleCommands.test.js

This file

Path

tests/help.visibleCommands.test.js

37 lines · 1.3 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 { test, describe } from 'node:test';
2import assert from 'node:assert/strict';3import * as commander from '../index.js';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 4–7why, 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).7

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

line 8why, one step back
8describe('Help.visibleCommands()', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 9–11why, one step back
9 test('when no subcommands then empty array', () => {
10 const program = new commander.Command();11 const helper = new commander.Help();

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

line 12why, one step back
12 assert.deepEqual(helper.visibleCommands(program), []);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 13–16why, one step back
13 });
1415 test('when add command then visible (with help)', () => {16 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 17why, one step back
17 program.command('sub');

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 19–21why, one step back
19 const visibleCommandNames = helper
20 .visibleCommands(program)21 .map((cmd) => cmd.name());

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

line 22why, one step back
22 assert.deepEqual(visibleCommandNames, ['sub', 'help']);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 23–29why, one step back
23 });
2425 test('when commands hidden then not visible', () => {26 const program = new commander.Command();27 program28 .command('visible', 'desc')29 .command('invisible-executable', 'desc', { hidden: true });

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 30why, one step back
30 program.command('invisible-action', { hidden: true });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 32–34why, one step back
32 const visibleCommandNames = helper
33 .visibleCommands(program)34 .map((cmd) => cmd.name());

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

line 35why, one step back
35 assert.deepEqual(visibleCommandNames, ['visible', 'help']);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 36–37why, one step back
36 });
37});