Skip to content
Myr

createCommand.test.js

This file

Path

tests/createCommand.test.js

36 lines · 1.0 KiB · JavaScript

Last changed by

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

History of this file

Take it

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

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

lines 1–14why, one step back
1const commander = require('../');
23test('when createCommand then unattached', () => {4 const program = new commander.Command();5 const cmd = program.createCommand();6 expect(program.commands.length).toBe(0);7 expect(cmd.parent).toBeFalsy(); // (actually null, but use weaker test for unattached)8});910test('when subclass overrides createCommand then subcommand is subclass', () => {11 class MyClass extends commander.Command {12 constructor(name) {13 super();14 this.myProperty = 'myClass';

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

line 15why, one step back
15 }

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

lines 16–18why, one step back
16
17 createCommand(name) {18 return new MyClass(name);

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

lines 19–20why, one step back
19 }
20 }

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

lines 21–36why, one step back
21 const program = new MyClass();
22 const sub = program.command('sub');23 expect(sub.myProperty).toEqual('myClass');24});2526test('when override createCommand then subcommand is custom', () => {27 function createCustom(name) {28 const cmd = new commander.Command();29 cmd.myProperty = 'custom';30 return cmd;31 }32 const program = createCustom();33 program.createCommand = createCustom;34 const sub = program.command('sub');35 expect(sub.myProperty).toEqual('custom');36});