Skip to content
Myr

command.chain.test.js

This file

Path

tests/command.chain.test.js

260 lines · 8.4 KiB · JavaScript

Last changed by

Refactor help option implementation to hold actual Option (#2006)John Geebefore adoption09244af

History of this file

Take it

The walk stopped after 200 commits: lines older than 20cef03 point at it.

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

line 1why, one step back
1const { Command, Option, Argument } = require('../');

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 2–15why, one step back
2
3// Testing the functions which should chain.4// parse and parseAsync are tested in command.parse.test.js56describe('Command methods that should return this for chaining', () => {7 test('when call .command() with description for stand-alone executable then returns this', () => {8 const program = new Command();9 const result = program.command('foo', 'foo description');10 expect(result).toBe(program);11 });1213 test('when call .addCommand() then returns this', () => {14 const program = new Command();15 const result = program.addCommand(new Command('name'));

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

lines 16–27why, one step back
16 expect(result).toBe(program);
17 });1819 test('when call .argument() then returns this', () => {20 const program = new Command();21 const result = program.argument('<file>');22 expect(result).toBe(program);23 });2425 test('when call .addArgument() then returns this', () => {26 const program = new Command();27 const result = program.addArgument(new Argument('<file>'));

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 28–36why, one step back
28 expect(result).toBe(program);
29 });3031 test('when set .arguments() then returns this', () => {32 const program = new Command();33 const result = program.arguments('<file>');34 expect(result).toBe(program);35 });36

Refactor help command implementation to hold actual Command (#2087)John Geebefore adoptionff08a02

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

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

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

Refactor help command implementation to hold actual Command (#2087)John Geebefore adoptionff08a02

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

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

line 40why, one step back
40 expect(result).toBe(program);

Refactor help command implementation to hold actual Command (#2087)John Geebefore adoptionff08a02

lines 41–82why, one step back
41 });
4243 test('when call deprecated .addHelpCommand() then returns this', () => {44 const program = new Command();45 const result = program.addHelpCommand();46 expect(result).toBe(program);47 });4849 test('when call deprecated .addHelpCommand(boolean) then returns this', () => {50 const program = new Command();51 const result1 = program.addHelpCommand(true);52 expect(result1).toBe(program);53 const result2 = program.addHelpCommand(false);54 expect(result2).toBe(program);55 });5657 test('when call deprecated .addHelpCommand(string[, string]) then returns this', () => {58 const program = new Command();59 const result1 = program.addHelpCommand('assist');60 expect(result1).toBe(program);61 const result2 = program.addHelpCommand('assist', 'assist description');62 expect(result2).toBe(program);63 });6465 test('when call .helpCommand(name) then returns this', () => {66 const program = new Command();67 const result = program.helpCommand();68 expect(result).toBe(program);69 });7071 test('when call .helpCommand(name, description) then returns this', () => {72 const program = new Command();73 const result1 = program.helpCommand('assist', 'assist description');74 expect(result1).toBe(program);75 });7677 test('when call .helpCommand(boolean) then returns this', () => {78 const program = new Command();79 const result1 = program.helpCommand(true);80 expect(result1).toBe(program);81 const result2 = program.helpCommand(false);82 expect(result2).toBe(program);

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 83–174why, one step back
83 });
8485 test('when call .exitOverride() then returns this', () => {86 const program = new Command();87 const result = program.exitOverride(() => { });88 expect(result).toBe(program);89 });9091 test('when call .action() then returns this', () => {92 const program = new Command();93 const result = program.action(() => { });94 expect(result).toBe(program);95 });9697 test('when call .addOption() then returns this', () => {98 const program = new Command();99 const result = program.addOption(new Option('-e'));100 expect(result).toBe(program);101 });102103 test('when call .option() then returns this', () => {104 const program = new Command();105 const result = program.option('-e');106 expect(result).toBe(program);107 });108109 test('when call .requiredOption() then returns this', () => {110 const program = new Command();111 const result = program.requiredOption('-r');112 expect(result).toBe(program);113 });114115 test('when call .combineFlagAndOptionalValue() then returns this', () => {116 const program = new Command();117 const result = program.combineFlagAndOptionalValue();118 expect(result).toBe(program);119 });120121 test('when call .allowUnknownOption() then returns this', () => {122 const program = new Command();123 const result = program.allowUnknownOption();124 expect(result).toBe(program);125 });126127 test('when call .allowExcessArguments() then returns this', () => {128 const program = new Command();129 const result = program.allowExcessArguments();130 expect(result).toBe(program);131 });132133 test('when call .storeOptionsAsProperties() then returns this', () => {134 const program = new Command();135 const result = program.storeOptionsAsProperties();136 expect(result).toBe(program);137 });138139 test('when call .version() then returns this', () => {140 const program = new Command();141 const result = program.version('1.2.3');142 expect(result).toBe(program);143 });144145 test('when set .description() then returns this', () => {146 const program = new Command();147 const result = program.description('description');148 expect(result).toBe(program);149 });150151 test('when set .alias() then returns this', () => {152 const program = new Command();153 const result = program.alias('alias');154 expect(result).toBe(program);155 });156157 test('when set .aliases() then returns this', () => {158 const program = new Command();159 const result = program.aliases(['foo', 'bar']);160 expect(result).toBe(program);161 });162163 test('when set .usage() then returns this', () => {164 const program = new Command();165 const result = program.usage('[options]');166 expect(result).toBe(program);167 });168169 test('when set .name() then returns this', () => {170 const program = new Command();171 const result = program.name('easy');172 expect(result).toBe(program);173 });174

Refactor help option implementation to hold actual Option (#2006)John Geebefore adoption09244af

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

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

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

Refactor help option implementation to hold actual Option (#2006)John Geebefore adoption09244af

lines 177–184why, one step back
177 const flags = '-h, --help';
178 const result = program.helpOption(flags);179 expect(result).toBe(program);180 });181182 test('when call .addHelpOption() then returns this', () => {183 const program = new Command();184 const result = program.addHelpOption(new Option('-h, --help'));

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

lines 185–204why, one step back
185 expect(result).toBe(program);
186 });187188 test('when call .addHelpText() then returns this', () => {189 const program = new Command();190 const result = program.addHelpText('before', 'example');191 expect(result).toBe(program);192 });193194 test('when call .configureHelp() then returns this', () => {195 const program = new Command();196 const result = program.configureHelp({ });197 expect(result).toBe(program);198 });199200 test('when call .configureOutput() then returns this', () => {201 const program = new Command();202 const result = program.configureOutput({ });203 expect(result).toBe(program);204 });

Positional options (#1427)John Geebefore adoption8ac84ec

lines 205–216why, one step back
205
206 test('when call .passThroughOptions() then returns this', () => {207 const program = new Command();208 const result = program.passThroughOptions();209 expect(result).toBe(program);210 });211212 test('when call .enablePositionalOptions() then returns this', () => {213 const program = new Command();214 const result = program.enablePositionalOptions();215 expect(result).toBe(program);216 });

Add getOptionValue and setOptionValue (#1521)John Geebefore adoption6c06528

line 217why, one step back
217

Add hooks for life cycle events: using .hook() (#1514)John Geebefore adoptionc20284d

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

Add getOptionValue and setOptionValue (#1521)John Geebefore adoption6c06528

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

Add setOptionValueWithSource and getOptionValueSource (#1613)John Geebefore adoption6e00f44

lines 226–232why, one step back
226 const result = program.setOptionValue('foo', 'bar');
227 expect(result).toBe(program);228 });229230 test('when call .setOptionValueWithSource() then returns this', () => {231 const program = new Command();232 const result = program.setOptionValueWithSource('foo', 'bar', 'cli');

Add getOptionValue and setOptionValue (#1521)John Geebefore adoption6c06528

lines 233–234why, one step back
233 expect(result).toBe(program);
234 });

Add showHelpAfterError (#1534)John Geebefore adoption082717f

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

Add copyInheritedSettings (#1557)John Geebefore adoption5517d25

line 241why, one step back
241

Suggestion for unknown command and unknown option (#1590)John Geebefore adoption91ccfd5

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

Add copyInheritedSettings (#1557)John Geebefore adoption5517d25

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

Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c

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

Update supported details for 7.x (#1419)John Geebefore adoption20cef03

line 260why, one step back
260});