Skip to content
Myr

createCommand.test.js

This file

Path

tests/createCommand.test.js

40 lines · 1.2 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 * as commander from '../index.js';
2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 40why, one step back
40});