command.unknownCommand.test.js
This file
Path
tests/command.unknownCommand.test.js
54 lines · 1.7 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 { createTestCommand } from './testHelpers.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
line 5why, one step back5describe('parsing unknown command', () => {Disallow excess arguments (#2223)John Geebefore adoption58c28eb
line 6why, one step back6 test('when unknown argument in simple program then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 7–8why, one step back7 const program = createTestCommand();8 assert.throws(() => {Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 9why, one step back9 program.parse('node test.js unknown'.split(' '));Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 10why, one step back10 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 11–13why, one step back11 });1213 test('when unknown command but action handler taking arg then no error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 14–15why, one step back14 const program = createTestCommand();15 program.command('sub');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 16why, one step back16 program.argument('[args...]').action(() => {});Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 17why, one step back17 assert.doesNotThrow(() => {Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 18why, one step back18 program.parse('node test.js unknown'.split(' '));Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 19why, one step back19 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 20–22why, one step back20 });2122 test('when unknown command but listener then no error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 23–24why, one step back23 const program = createTestCommand();24 program.command('sub');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 25why, one step back25 program.on('command:*', () => {});Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 26why, one step back26 assert.doesNotThrow(() => {Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 27why, one step back27 program.parse('node test.js unknown'.split(' '));Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 28why, one step back28 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 29–31why, one step back29 });3031 test('when unknown command then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 32–39why, one step back32 const program = createTestCommand();33 program.command('sub');34 assert.throws(35 () => {36 program.parse('node test.js unknown'.split(' '));37 },38 { code: 'commander.unknownCommand' },39 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 40–44why, one step back40 });4142 test('when unknown command and unknown option then error is for unknown command', () => {43 // The unknown command is more useful since the option is for an unknown command (and might be44 // ok if the command had been correctly spelled, say).Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 45–52why, one step back45 const program = createTestCommand();46 program.command('sub');47 assert.throws(48 () => {49 program.parse('node test.js sbu --silly'.split(' '));50 },51 { code: 'commander.unknownCommand' },52 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 53–54why, one step back53 });54});