Skip to content
Myr

help.longestCommandTermLength.test.js

This file

Path

tests/help.longestCommandTermLength.test.js

61 lines · 2.1 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.longestSubcommandTermLength()', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 9–11why, one step back
9 test('when no commands then returns zero', () => {
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.equal(helper.longestSubcommandTermLength(program, helper), 0);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 13–17why, one step back
13 });
1415 test('when command and no help then returns length of term', () => {16 const sub = new commander.Command('sub');17 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 18why, one step back
18 program.addHelpCommand(false).addCommand(sub);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

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

lines 20–21why, one step back
20 assert.equal(
21 helper.longestSubcommandTermLength(program, helper),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 22–23why, one step back
22 helper.subcommandTerm(sub).length,
23 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 24–28why, one step back
24 });
2526 test('when command with arg and no help then returns length of term', () => {27 const sub = new commander.Command('sub <file)');28 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 29why, one step back
29 program.addHelpCommand(false).addCommand(sub);

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

lines 31–32why, one step back
31 assert.equal(
32 helper.longestSubcommandTermLength(program, helper),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 33–34why, one step back
33 helper.subcommandTerm(sub).length,
34 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 35–45why, one step back
35 });
3637 test('when multiple commands then returns longest length', () => {38 const longestCommandName = 'alphabet-soup <longer_than_help>';39 const program = new commander.Command();40 program41 .addHelpCommand(false)42 .command('before', 'desc')43 .command(longestCommandName, 'desc')44 .command('after', 'desc');45 const helper = new commander.Help();

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

lines 46–47why, one step back
46 assert.equal(
47 helper.longestSubcommandTermLength(program, helper),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 48–49why, one step back
48 longestCommandName.length,
49 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 50–53why, one step back
50 });
5152 test('when just help command then returns length of help term', () => {53 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 54why, one step back
54 program.addHelpCommand(true);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

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

lines 56–57why, one step back
56 assert.equal(
57 helper.longestSubcommandTermLength(program, helper),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 58–59why, one step back
58 'help [command]'.length,
59 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 60–61why, one step back
60 });
61});