Skip to content
Myr

command.allowUnknownOption.test.js

This file

Path

tests/command.allowUnknownOption.test.js

79 lines · 2.3 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// Not testing output, just testing whether an error is detected.6

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

line 7why, one step back
7describe('Command.allowUnknownOption()', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 8why, one step back
8 test('when specify unknown program option 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.option('-p, --pepper', 'add pepper');

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

line 12why, one step back
12 assert.throws(() => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 13why, one step back
13 program.parse(['node', 'test', '-m']);

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

line 14why, one step back
14 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 15–17why, one step back
15 });
1617 test('when specify unknown program option and allowUnknownOption(false) then error', () => {

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

lines 18–19why, one step back
18 const program = createTestCommand();
19 program.allowUnknownOption(false).option('-p, --pepper', 'add pepper');

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 20why, one step back
20

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

line 21why, one step back
21 assert.throws(() => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 22why, one step back
22 program.parse(['node', 'test', '-m']);

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

line 23why, one step back
23 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 24–26why, one step back
24 });
2526 test('when specify unknown program option and allowUnknownOption() then no error', () => {

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 28why, one step back
28 program

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

line 29why, one step back
29

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 30why, one step back
30 .allowUnknownOption()

Disallow excess arguments (#2223)John Geebefore adoption58c28eb

line 31why, one step back
31 .argument('[args...]') // unknown option will be passed as an argument

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 32–33why, one step back
32 .option('-p, --pepper', 'add pepper');
33

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 35why, one step back
35 program.parse(['node', 'test', '-m']);

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

line 36why, one step back
36 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 37–39why, one step back
37 });
3839 test('when specify unknown program option and allowUnknownOption(true) then no error', () => {

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 41why, one step back
41 program

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

line 42why, one step back
42

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 43why, one step back
43 .allowUnknownOption(true)

Disallow excess arguments (#2223)John Geebefore adoption58c28eb

line 44why, one step back
44 .argument('[args...]') // unknown option will be passed as an argument

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 45–46why, one step back
45 .option('-p, --pepper', 'add pepper');
46

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 48why, one step back
48 program.parse(['node', 'test', '-m']);

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

line 49why, one step back
49 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 50–52why, one step back
50 });
5152 test('when specify unknown command option then error', () => {

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 54why, one step back
54 program

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

line 55why, one step back
55

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 56–57why, one step back
56 .command('sub')
57 .option('-p, --pepper', 'add pepper')

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 58why, one step back
58 .action(() => {});

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 59why, one step back
59

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

line 60why, one step back
60 assert.throws(() => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 61why, one step back
61 program.parse(['node', 'test', 'sub', '-m']);

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

line 62why, one step back
62 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 63–65why, one step back
63 });
6465 test('when specify unknown command option and allowUnknownOption then no error', () => {

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 67why, one step back
67 program

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

line 68why, one step back
68

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 69–72why, one step back
69 .command('sub')
70 .argument('[args...]') // unknown option will be passed as an argument71 .allowUnknownOption()72 .option('-p, --pepper', 'add pepper')

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 73why, one step back
73 .action(() => {});

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 74why, one step back
74

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

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

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 76why, one step back
76 program.parse(['node', 'test', 'sub', '-m']);

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

line 77why, one step back
77 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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