Skip to content
Myr

command.allowExcessArguments.test.js

This file

Path

tests/command.allowExcessArguments.test.js

115 lines · 3.8 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.allowExcessArguments()', () => {

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

lines 8–12why, one step back
8 const cases = [true, false];
9 cases.forEach((hasActionHandler) => {10 describe(`when ${hasActionHandler ? 'has' : 'no'} action handler`, () => {11 function configureCommand(cmd) {12 if (hasActionHandler) cmd.action(() => {});

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 13why, one step back
13 }

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 14why, one step back
14

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

lines 15–17why, one step back
15 test('when specify excess program argument then error by default', () => {
16 const program = createTestCommand();17 configureCommand(program);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 18why, one step back
18

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

lines 19–22why, one step back
19 assert.throws(() => {
20 program.parse(['excess'], { from: 'user' });21 });22 });

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–27why, one step back
24 test('when specify excess program argument and allowExcessArguments(false) then error', () => {
25 const program = createTestCommand();26 configureCommand(program);27 program.allowExcessArguments(false);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 28why, one step back
28

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

lines 29–32why, one step back
29 assert.throws(() => {
30 program.parse(['excess'], { from: 'user' });31 });32 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 33why, one step back
33

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

lines 34–37why, one step back
34 test('when specify excess program argument and allowExcessArguments() then no error', () => {
35 const program = createTestCommand();36 configureCommand(program);37 program.allowExcessArguments();

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 38why, one step back
38

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

lines 39–42why, one step back
39 assert.doesNotThrow(() => {
40 program.parse(['excess'], { from: 'user' });41 });42 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 43why, one step back
43

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

lines 44–47why, one step back
44 test('when specify excess program argument and allowExcessArguments(true) then no error', () => {
45 const program = createTestCommand();46 configureCommand(program);47 program.allowExcessArguments(true);

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–52why, one step back
49 assert.doesNotThrow(() => {
50 program.parse(['excess'], { from: 'user' });51 });52 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 53why, one step back
53

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

lines 54–57why, one step back
54 test('when specify excess command argument then error (by default)', () => {
55 const program = createTestCommand();56 const sub = program.command('sub');57 configureCommand(sub);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 58why, one step back
58

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

lines 59–62why, one step back
59 assert.throws(() => {
60 program.parse(['sub', 'excess'], { from: 'user' });61 });62 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 63why, one step back
63

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

lines 64–67why, one step back
64 test('when specify excess command argument and allowExcessArguments(false) then error', () => {
65 const program = createTestCommand();66 const sub = program.command('sub').allowExcessArguments(false);67 configureCommand(sub);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 68why, one step back
68

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

lines 69–72why, one step back
69 assert.throws(() => {
70 program.parse(['sub', 'excess'], { from: 'user' });71 });72 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 73why, one step back
73

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

lines 74–77why, one step back
74 test('when specify expected arg and allowExcessArguments(false) then no error', () => {
75 const program = createTestCommand();76 configureCommand(program);77 program.argument('<file>').allowExcessArguments(false);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 78why, one step back
78

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

lines 79–82why, one step back
79 assert.doesNotThrow(() => {
80 program.parse(['file'], { from: 'user' });81 });82 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 83why, one step back
83

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

lines 84–87why, one step back
84 test('when specify excess after <arg> and allowExcessArguments(false) then error', () => {
85 const program = createTestCommand();86 configureCommand(program);87 program.argument('<file>').allowExcessArguments(false);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 88why, one step back
88

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

lines 89–92why, one step back
89 assert.throws(() => {
90 program.parse(['file', 'excess'], { from: 'user' });91 });92 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 93why, one step back
93

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

lines 94–97why, one step back
94 test('when specify excess after [arg] and allowExcessArguments(false) then error', () => {
95 const program = createTestCommand();96 configureCommand(program);97 program.argument('[file]').allowExcessArguments(false);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 98why, one step back
98

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

lines 99–102why, one step back
99 assert.throws(() => {
100 program.parse(['file', 'excess'], { from: 'user' });101 });102 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 103why, one step back
103

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

lines 104–107why, one step back
104 test('when specify args for [args...] and allowExcessArguments(false) then no error', () => {
105 const program = createTestCommand();106 configureCommand(program);107 program.argument('[files...]').allowExcessArguments(false);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 108why, one step back
108

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

lines 109–112why, one step back
109 assert.doesNotThrow(() => {
110 program.parse(['file1', 'file2', 'file3'], { from: 'user' });111 });112 });

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 113why, one step back
113 });

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

lines 114–115why, one step back
114 });
115});