Skip to content
Myr

command.unknownOption.test.js

This file

Path

tests/command.unknownOption.test.js

78 lines · 2.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 { createTestCommand } from './testHelpers.js';
2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 4–6why, one step back
4
5// Checking for detection of unknown options, including regression tests for some past issues.6

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

line 7why, one step back
7describe('parsing unknown option', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 8why, one step back
8 test('when specify unknown option with subcommand and action handler then error', () => {

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

lines 9–10why, one step back
9 const program = createTestCommand();
10 program.command('info').action(() => {});

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 11why, one step back
11

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

lines 12–17why, one step back
12 assert.throws(
13 () => {14 program.parse(['node', 'test', 'info', '--NONSENSE']);15 },16 { code: 'commander.unknownOption' },17 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 18–20why, one step back
18 });
1920 test('when specify unknown option with subcommand argument and action handler then error', () => {

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

lines 21–22why, one step back
21 const program = createTestCommand();
22 program.command('info <file>').action(() => {});

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 23why, one step back
23

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

lines 24–29why, one step back
24 assert.throws(
25 () => {26 program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);27 },28 { code: 'commander.unknownOption' },29 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 30–32why, one step back
30 });
3132 test('when specify unknown option with program and action handler then error', () => {

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

lines 33–34why, one step back
33 const program = createTestCommand();
34 program.argument('[file]').action(() => {});

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 35why, one step back
35

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

lines 36–41why, one step back
36 assert.throws(
37 () => {38 program.parse(['node', 'test', '--NONSENSE']);39 },40 { code: 'commander.unknownOption' },41 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 42–45why, one step back
42 });
4344 test('when specify unknown option with program argument and action handler then error', () => {45 // Regression test from #965

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

lines 46–47why, one step back
46 const program = createTestCommand();
47 program.argument('[file]').action(() => {});

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 48why, one step back
48

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

lines 49–54why, one step back
49 assert.throws(
50 () => {51 program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);52 },53 { code: 'commander.unknownOption' },54 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 55–57why, one step back
55 });
5657 test('when specify unknown option with simple program then error', () => {

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

lines 58–64why, one step back
58 const program = createTestCommand();
59 assert.throws(60 () => {61 program.parse(['node', 'test', '--NONSENSE']);62 },63 { code: 'commander.unknownOption' },64 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 65–67why, one step back
65 });
6667 test('when specify unknown global option before subcommand then error', () => {

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

line 68why, one step back
68 const program = createTestCommand();

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 69–70why, one step back
69 program.command('sub');
70

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

lines 71–76why, one step back
71 assert.throws(
72 () => {73 program.parse(['--NONSENSE', 'sub'], { from: 'user' });74 },75 { code: 'commander.unknownOption' },76 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 77–78why, one step back
77 });
78});