Skip to content
Myr

help.sortCommands.test.js

This file

Path

tests/help.sortCommands.test.js

35 lines · 1.2 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–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.configureHelp({ sortSubcommands: true })', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 9–15why, one step back
9 test('when unsorted then commands in order added', () => {
10 const program = new commander.Command();11 program12 .command('ccc', 'desc')13 .command('aaa', 'desc')14 .command('bbb', 'desc');15 const helper = program.createHelp();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 16–18why, one step back
16 const visibleCommandNames = helper
17 .visibleCommands(program)18 .map((cmd) => cmd.name());

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

line 19why, one step back
19 assert.deepEqual(visibleCommandNames, ['ccc', 'aaa', 'bbb', 'help']);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 20–29why, one step back
20 });
2122 test('when sortSubcommands:true then commands sorted', () => {23 const program = new commander.Command();24 program25 .configureHelp({ sortSubcommands: true })26 .command('ccc', 'desc')27 .command('aaa', 'desc')28 .command('bbb', 'desc');29 const helper = program.createHelp();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

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

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

line 33why, one step back
33 assert.deepEqual(visibleCommandNames, ['aaa', 'bbb', 'ccc', 'help']);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 34–35why, one step back
34 });
35});