Skip to content
Myr

help.visibleArguments.test.js

This file

Path

tests/help.visibleArguments.test.js

79 lines · 2.8 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.visibleArguments()', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 9–11why, one step back
9 test('when no arguments 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.visibleArguments(program), []);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 13–18why, one step back
13 });
1415 test('when argument but no argument description then empty array', () => {16 const program = new commander.Command();17 program.argument('<file>');18 const helper = new commander.Help();

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 20–26why, one step back
20 });
2122 test('when argument and argument description then returned', () => {23 const program = new commander.Command();24 program.argument('<file>', 'file description');25 const helper = new commander.Help();26 const visibleArguments = helper.visibleArguments(program);

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

lines 27–29why, one step back
27 assert.equal(visibleArguments.length, 1);
28 assert.deepEqual(29 visibleArguments[0],

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 30–31why, one step back
30 new commander.Argument('<file>', 'file description'),
31 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 32–37why, one step back
32 });
3334 test('when argument and legacy argument description then returned', () => {35 const program = new commander.Command();36 program.argument('<file>');37 program.description('', {

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 38why, one step back
38 file: 'file description',

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 39–41why, one step back
39 });
40 const helper = new commander.Help();41 const visibleArguments = helper.visibleArguments(program);

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

lines 42–44why, one step back
42 assert.equal(visibleArguments.length, 1);
43 assert.deepEqual(44 visibleArguments[0],

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 45–46why, one step back
45 new commander.Argument('<file>', 'file description'),
46 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 47–54why, one step back
47 });
4849 test('when arguments and some described then all returned', () => {50 const program = new commander.Command();51 program.argument('<file1>', 'file1 description');52 program.argument('<file2>');53 const helper = new commander.Help();54 const visibleArguments = helper.visibleArguments(program);

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

lines 55–57why, one step back
55 assert.equal(visibleArguments.length, 2);
56 assert.deepEqual(57 visibleArguments[0],

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 58–59why, one step back
58 new commander.Argument('<file1>', 'file1 description'),
59 );

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

line 60why, one step back
60 assert.deepEqual(visibleArguments[1], new commander.Argument('<file2>'));

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 61–67why, one step back
61 });
6263 test('when arguments and some legacy described then all returned', () => {64 const program = new commander.Command();65 program.argument('<file1>');66 program.argument('<file2>');67 program.description('', {

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 68why, one step back
68 file1: 'file1 description',

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 69–71why, one step back
69 });
70 const helper = new commander.Help();71 const visibleArguments = helper.visibleArguments(program);

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

lines 72–74why, one step back
72 assert.equal(visibleArguments.length, 2);
73 assert.deepEqual(74 visibleArguments[0],

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 75–76why, one step back
75 new commander.Argument('<file1>', 'file1 description'),
76 );

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

line 77why, one step back
77 assert.deepEqual(visibleArguments[1], new commander.Argument('<file2>'));

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 78–79why, one step back
78 });
79});