Skip to content
Myr

help.visibleCommands.test.js

This file

Path

tests/help.visibleCommands.test.js

33 lines · 1.2 KiB · JavaScript

Last changed by

Fix syntactically incorrect command name (#1488)John Geebefore adoption7b6567e

History of this file

Take it

Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912

lines 1–25why, 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).56describe('visibleCommands', () => {7 test('when no subcommands then empty array', () => {8 const program = new commander.Command();9 const helper = new commander.Help();10 expect(helper.visibleCommands(program)).toEqual([]);11 });1213 test('when add command then visible (with help)', () => {14 const program = new commander.Command();15 program16 .command('sub');17 const helper = new commander.Help();18 const visibleCommandNames = helper.visibleCommands(program).map(cmd => cmd.name());19 expect(visibleCommandNames).toEqual(['sub', 'help']);20 });2122 test('when commands hidden then not visible', () => {23 const program = new commander.Command();24 program25 .command('visible', 'desc')

Fix syntactically incorrect command name (#1488)John Geebefore adoption7b6567e

line 26why, one step back
26 .command('invisible-executable', 'desc', { hidden: true });

Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912

line 27why, one step back
27 program

Fix syntactically incorrect command name (#1488)John Geebefore adoption7b6567e

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

Refactor help internals into separate interface/class (#1365)John Geebefore adoption19ae912

lines 29–33why, one step back
29 const helper = new commander.Help();
30 const visibleCommandNames = helper.visibleCommands(program).map(cmd => cmd.name());31 expect(visibleCommandNames).toEqual(['visible', 'help']);32 });33});