Skip to content
Myr

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 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 { 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 back
4

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

line 5why, one step back
5describe('parsing unknown command', () => {

Disallow excess arguments (#2223)John Geebefore adoption58c28eb

line 6why, one step back
6 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 back
7 const program = createTestCommand();
8 assert.throws(() => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 9why, one step back
9 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 back
10 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 11–13why, one step back
11 });
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 back
14 const program = createTestCommand();
15 program.command('sub');

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 16why, one step back
16 program.argument('[args...]').action(() => {});

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

line 17why, one step back
17 assert.doesNotThrow(() => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 18why, one step back
18 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 back
19 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 20–22why, one step back
20 });
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 back
23 const program = createTestCommand();
24 program.command('sub');

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 25why, one step back
25 program.on('command:*', () => {});

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

line 26why, one step back
26 assert.doesNotThrow(() => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 27why, one step back
27 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 back
28 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 29–31why, one step back
29 });
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 back
32 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 back
40 });
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 back
45 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 back
53 });
54});