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 fileTake 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 back1import * 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 back4Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 5–11why, one step back5describe('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 back12Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 13–18why, one step back13 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 back19Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 20–22why, one step back20 createCommand(name) {21 return new MyClass(name);22 }Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 23why, one step back23 }Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 24–27why, one step back24 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 back28Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 29–39why, one step back29 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 back40});