Skip to content
Myr

command.chain.test.js

This file

Path

tests/command.chain.test.js

280 lines · 9.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 { Command, Option, Argument } 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–11why, one step back
4
5// Testing the functions which should chain.6// parse and parseAsync are tested in command.parse.test.js78describe('Command methods that should return this for chaining', () => {9 test('when call .command() with description for stand-alone executable then returns this', () => {10 const program = new Command();11 const result = program.command('foo', 'foo description');

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

line 12why, one step back
12 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 13–17why, one step back
13 });
1415 test('when call .addCommand() then returns this', () => {16 const program = new Command();17 const result = program.addCommand(new Command('name'));

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

line 18why, one step back
18 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 19–23why, one step back
19 });
2021 test('when call .argument() then returns this', () => {22 const program = new Command();23 const result = program.argument('<file>');

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

line 24why, one step back
24 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 25–29why, one step back
25 });
2627 test('when call .addArgument() then returns this', () => {28 const program = new Command();29 const result = program.addArgument(new Argument('<file>'));

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

line 30why, one step back
30 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 31–35why, one step back
31 });
3233 test('when set .arguments() then returns this', () => {34 const program = new Command();35 const result = program.arguments('<file>');

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

line 36why, one step back
36 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 39why, one step back
39 test('when call .addHelpCommand(cmd) then returns this', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 40why, one step back
40 const program = new Command();

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 41why, one step back
41 const result = program.addHelpCommand(new Command('assist'));

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

line 42why, one step back
42 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 43–44why, one step back
43 });
44

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 45–47why, one step back
45 test('when call deprecated .addHelpCommand() then returns this', () => {
46 const program = new Command();47 const result = program.addHelpCommand();

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

line 48why, one step back
48 assert.equal(result, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 49–53why, one step back
49 });
5051 test('when call deprecated .addHelpCommand(boolean) then returns this', () => {52 const program = new Command();53 const result1 = program.addHelpCommand(true);

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

line 54why, one step back
54 assert.equal(result1, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 55why, one step back
55 const result2 = program.addHelpCommand(false);

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

line 56why, one step back
56 assert.equal(result2, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 57–61why, one step back
57 });
5859 test('when call deprecated .addHelpCommand(string[, string]) then returns this', () => {60 const program = new Command();61 const result1 = program.addHelpCommand('assist');

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

line 62why, one step back
62 assert.equal(result1, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 63why, one step back
63 const result2 = program.addHelpCommand('assist', 'assist description');

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

line 64why, one step back
64 assert.equal(result2, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 65–69why, one step back
65 });
6667 test('when call .helpCommand(name) then returns this', () => {68 const program = new Command();69 const result = program.helpCommand();

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

line 70why, one step back
70 assert.equal(result, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 71–75why, one step back
71 });
7273 test('when call .helpCommand(name, description) then returns this', () => {74 const program = new Command();75 const result1 = program.helpCommand('assist', 'assist description');

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

line 76why, one step back
76 assert.equal(result1, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 77–81why, one step back
77 });
7879 test('when call .helpCommand(boolean) then returns this', () => {80 const program = new Command();81 const result1 = program.helpCommand(true);

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

line 82why, one step back
82 assert.equal(result1, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 83why, one step back
83 const result2 = program.helpCommand(false);

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

line 84why, one step back
84 assert.equal(result2, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 85–86why, one step back
85 });
86

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 87–88why, one step back
87 test('when call .exitOverride() then returns this', () => {
88 const program = new Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 89why, one step back
89 const result = program.exitOverride(() => {});

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

line 90why, one step back
90 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 91–94why, one step back
91 });
9293 test('when call .action() then returns this', () => {94 const program = new Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 95why, one step back
95 const result = program.action(() => {});

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

line 96why, one step back
96 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 97–101why, one step back
97 });
9899 test('when call .addOption() then returns this', () => {100 const program = new Command();101 const result = program.addOption(new Option('-e'));

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

line 102why, one step back
102 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 103–107why, one step back
103 });
104105 test('when call .option() then returns this', () => {106 const program = new Command();107 const result = program.option('-e');

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

line 108why, one step back
108 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 109–113why, one step back
109 });
110111 test('when call .requiredOption() then returns this', () => {112 const program = new Command();113 const result = program.requiredOption('-r');

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

line 114why, one step back
114 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 115–119why, one step back
115 });
116117 test('when call .combineFlagAndOptionalValue() then returns this', () => {118 const program = new Command();119 const result = program.combineFlagAndOptionalValue();

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

line 120why, one step back
120 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 121–125why, one step back
121 });
122123 test('when call .allowUnknownOption() then returns this', () => {124 const program = new Command();125 const result = program.allowUnknownOption();

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

line 126why, one step back
126 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 127–131why, one step back
127 });
128129 test('when call .allowExcessArguments() then returns this', () => {130 const program = new Command();131 const result = program.allowExcessArguments();

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

line 132why, one step back
132 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 133–137why, one step back
133 });
134135 test('when call .storeOptionsAsProperties() then returns this', () => {136 const program = new Command();137 const result = program.storeOptionsAsProperties();

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

line 138why, one step back
138 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 139–143why, one step back
139 });
140141 test('when call .version() then returns this', () => {142 const program = new Command();143 const result = program.version('1.2.3');

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

line 144why, one step back
144 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 145–149why, one step back
145 });
146147 test('when set .description() then returns this', () => {148 const program = new Command();149 const result = program.description('description');

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

line 150why, one step back
150 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 151–155why, one step back
151 });
152153 test('when set .alias() then returns this', () => {154 const program = new Command();155 const result = program.alias('alias');

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

line 156why, one step back
156 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 157–161why, one step back
157 });
158159 test('when set .aliases() then returns this', () => {160 const program = new Command();161 const result = program.aliases(['foo', 'bar']);

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

line 162why, one step back
162 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 163–167why, one step back
163 });
164165 test('when set .usage() then returns this', () => {166 const program = new Command();167 const result = program.usage('[options]');

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

line 168why, one step back
168 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 169–173why, one step back
169 });
170171 test('when set .name() then returns this', () => {172 const program = new Command();173 const result = program.name('easy');

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

line 174why, one step back
174 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 175–176why, one step back
175 });
176

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 177why, one step back
177 test('when call .helpOption(flags) then returns this', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 178why, one step back
178 const program = new Command();

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 179–180why, one step back
179 const flags = '-h, --help';
180 const result = program.helpOption(flags);

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

line 181why, one step back
181 assert.equal(result, program);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 182–186why, one step back
182 });
183184 test('when call .addHelpOption() then returns this', () => {185 const program = new Command();186 const result = program.addHelpOption(new Option('-h, --help'));

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

line 187why, one step back
187 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 188–192why, one step back
188 });
189190 test('when call .addHelpText() then returns this', () => {191 const program = new Command();192 const result = program.addHelpText('before', 'example');

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

line 193why, one step back
193 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 194–197why, one step back
194 });
195196 test('when call .configureHelp() then returns this', () => {197 const program = new Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 198why, one step back
198 const result = program.configureHelp({});

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

line 199why, one step back
199 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 200–203why, one step back
200 });
201202 test('when call .configureOutput() then returns this', () => {203 const program = new Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 204why, one step back
204 const result = program.configureOutput({});

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

line 205why, one step back
205 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 206–210why, one step back
206 });
207208 test('when call .passThroughOptions() then returns this', () => {209 const program = new Command();210 const result = program.passThroughOptions();

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

line 211why, one step back
211 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 212–216why, one step back
212 });
213214 test('when call .enablePositionalOptions() then returns this', () => {215 const program = new Command();216 const result = program.enablePositionalOptions();

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

line 217why, one step back
217 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 218–222why, one step back
218 });
219220 test('when call .hook() then returns this', () => {221 const program = new Command();222 const result = program.hook('preAction', () => {});

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

line 223why, one step back
223 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 224–228why, one step back
224 });
225226 test('when call .setOptionValue() then returns this', () => {227 const program = new Command();228 const result = program.setOptionValue('foo', 'bar');

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

line 229why, one step back
229 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 230–234why, one step back
230 });
231232 test('when call .setOptionValueWithSource() then returns this', () => {233 const program = new Command();234 const result = program.setOptionValueWithSource('foo', 'bar', 'cli');

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

line 235why, one step back
235 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 236–240why, one step back
236 });
237238 test('when call .showHelpAfterError() then returns this', () => {239 const program = new Command();240 const result = program.showHelpAfterError();

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

line 241why, one step back
241 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 242–246why, one step back
242 });
243244 test('when call .showSuggestionAfterError() then returns this', () => {245 const program = new Command();246 const result = program.showSuggestionAfterError();

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

line 247why, one step back
247 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 248–253why, one step back
248 });
249250 test('when call .copyInheritedSettings() then returns this', () => {251 const program = new Command();252 const cmd = new Command();253 const result = cmd.copyInheritedSettings(program);

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

line 254why, one step back
254 assert.equal(result, cmd);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 255–259why, one step back
255 });
256257 test('when set .nameFromFilename() then returns this', () => {258 const program = new Command();259 const result = program.nameFromFilename('name');

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

line 260why, one step back
260 assert.equal(result, program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 261why, one step back
261 });

Add support for groups of options and commands in the help (#2328)John Geebefore adoptionc324ea3

lines 262–265why, one step back
262
263 test('when set .helpGroup(heading) then returns this', () => {264 const program = new Command();265 const result = program.helpGroup('Commands:');

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

line 266why, one step back
266 assert.equal(result, program);

Add support for groups of options and commands in the help (#2328)John Geebefore adoptionc324ea3

lines 267–271why, one step back
267 });
268269 test('when set .commandsGroup(heading) then returns this', () => {270 const program = new Command();271 const result = program.commandsGroup('Commands:');

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

line 272why, one step back
272 assert.equal(result, program);

Add support for groups of options and commands in the help (#2328)John Geebefore adoptionc324ea3

lines 273–277why, one step back
273 });
274275 test('when set .optionsGroup(heading) then returns this', () => {276 const program = new Command();277 const result = program.optionsGroup('Options:');

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

line 278why, one step back
278 assert.equal(result, program);

Add support for groups of options and commands in the help (#2328)John Geebefore adoptionc324ea3

line 279why, one step back
279 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 280why, one step back
280});