Skip to content
Myr

createCommand.test.js

This file

Path

tests/createCommand.test.js

40 lines · 1.2 KiB · JavaScript

Last changed by

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

History of this file

Take it

The walk stopped after 200 commits: lines older than 3103c6b point at it.

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 1why, one step back
1const commander = require('../');

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

line 2why, one step back
2const { test, describe } = require('node:test');

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

line 3why, one step back
3const assert = require('node:assert/strict');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 4why, one step back
4

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 5–11why, one step back
5describe('Command.createCommand()', () => {
6 test('when createCommand then unattached', () => {7 const program = new commander.Command();8 const cmd = program.createCommand();9 assert.equal(program.commands.length, 0);10 assert.equal(cmd.parent, null);11 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 12why, one step back
12

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 13–18why, one step back
13 test('when subclass overrides createCommand then subcommand is subclass', () => {
14 class MyClass extends commander.Command {15 constructor(name) {16 super();17 this.myProperty = 'myClass';18 }

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 19why, one step back
19

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 20–22why, one step back
20 createCommand(name) {
21 return new MyClass(name);22 }

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 23why, one step back
23 }

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 24–27why, one step back
24 const program = new MyClass();
25 const sub = program.command('sub');26 assert.equal(sub.myProperty, 'myClass');27 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 28why, one step back
28

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 29–39why, one step back
29 test('when override createCommand then subcommand is custom', () => {
30 function createCustom(name) {31 const cmd = new commander.Command();32 cmd.myProperty = 'custom';33 return cmd;34 }35 const program = createCustom();36 program.createCommand = createCustom;37 const sub = program.command('sub');38 assert.equal(sub.myProperty, 'custom');39 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 40why, one step back
40});