command.createArgument.test.js
This file
Path
tests/command.createArgument.test.js
44 lines · 1.4 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
lines 4–22why, one step back45class MyArgument extends commander.Argument {6 constructor(name, description) {7 super(name, description);8 this.myProperty = 'MyArgument';9 }10}1112class MyCommand extends commander.Command {13 createArgument(name, description) {14 return new MyArgument(name, description);15 }1617 // createCommand for testing .command('sub <file>')18 createCommand(name) {19 return new MyCommand(name);20 }21}22Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 23–29why, one step back23describe('Command.createArgument() override in subclass', () => {24 test('when override createArgument then used for argument()', () => {25 const program = new MyCommand();26 program.argument('<file>');27 assert.equal(program.registeredArguments.length, 1);28 assert.equal(program.registeredArguments[0].myProperty, 'MyArgument');29 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 30why, one step back30Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 31–36why, one step back31 test('when override createArgument then used for arguments()', () => {32 const program = new MyCommand();33 program.arguments('<file>');34 assert.equal(program.registeredArguments.length, 1);35 assert.equal(program.registeredArguments[0].myProperty, 'MyArgument');36 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 37why, one step back37Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 38–43why, one step back38 test('when override createArgument and createCommand then used for argument of command()', () => {39 const program = new MyCommand();40 const sub = program.command('sub <file>');41 assert.equal(sub.registeredArguments.length, 1);42 assert.equal(sub.registeredArguments[0].myProperty, 'MyArgument');43 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 44why, one step back44});