Skip to content
Myr

command.createArgument.test.js

This file

Path

tests/command.createArgument.test.js

40 lines · 1.3 KiB · JavaScript

Last changed by

Merge remote-tracking branch 'origin/develop' into release/12.xJohn Geebefore adoption9afbabd

History of this file

Take it

Factory routine to create a new unattached argument (#1497)Sergei Vizelbefore adoption387b6fc

lines 1–6why, one step back
1const commander = require('../');
23class MyArgument extends commander.Argument {4 constructor(name, description) {5 super(name, description);6 this.myProperty = 'MyArgument';

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

line 7why, one step back
7 }

Factory routine to create a new unattached argument (#1497)Sergei Vizelbefore adoption387b6fc

lines 8–12why, one step back
8}
910class MyCommand extends commander.Command {11 createArgument(name, description) {12 return new MyArgument(name, description);

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

line 13why, one step back
13 }

Factory routine to create a new unattached argument (#1497)Sergei Vizelbefore adoption387b6fc

lines 14–23why, one step back
14
15 // createCommand for testing .command('sub <file>')16 createCommand(name) {17 return new MyCommand(name);18 }19}2021test('when override createArgument then used for argument()', () => {22 const program = new MyCommand();23 program.argument('<file>');

Merge remote-tracking branch 'origin/develop' into release/12.xJohn Geebefore adoption9afbabd

lines 24–25why, one step back
24 expect(program.registeredArguments.length).toEqual(1);
25 expect(program.registeredArguments[0].myProperty).toEqual('MyArgument');

Factory routine to create a new unattached argument (#1497)Sergei Vizelbefore adoption387b6fc

lines 26–30why, one step back
26});
2728test('when override createArgument then used for arguments()', () => {29 const program = new MyCommand();30 program.arguments('<file>');

Merge remote-tracking branch 'origin/develop' into release/12.xJohn Geebefore adoption9afbabd

lines 31–32why, one step back
31 expect(program.registeredArguments.length).toEqual(1);
32 expect(program.registeredArguments[0].myProperty).toEqual('MyArgument');

Factory routine to create a new unattached argument (#1497)Sergei Vizelbefore adoption387b6fc

lines 33–37why, one step back
33});
3435test('when override createArgument and createCommand then used for argument of command()', () => {36 const program = new MyCommand();37 const sub = program.command('sub <file>');

Merge remote-tracking branch 'origin/develop' into release/12.xJohn Geebefore adoption9afbabd

lines 38–39why, one step back
38 expect(sub.registeredArguments.length).toEqual(1);
39 expect(sub.registeredArguments[0].myProperty).toEqual('MyArgument');

Factory routine to create a new unattached argument (#1497)Sergei Vizelbefore adoption387b6fc

line 40why, one step back
40});