command.unknownOption.test.js
This file
Path
tests/command.unknownOption.test.js
78 lines · 2.3 KiB · JavaScript
Last changed by
Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
History of this fileTake it
The walk stopped after 200 commits: lines older than 3103c6b point at it.
Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 1–3why, one step back1const { createTestCommand } = require('./testHelpers');2const { test, describe } = require('node:test');3const assert = require('node:assert/strict');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 4–6why, one step back45// Checking for detection of unknown options, including regression tests for some past issues.6Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 7why, one step back7describe('parsing unknown option', () => {Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 8why, one step back8 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 back9 const program = createTestCommand();10 program.command('info').action(() => {});Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 11why, one step back11Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 12–17why, one step back12 assert.throws(13 () => {14 program.parse(['node', 'test', 'info', '--NONSENSE']);15 },16 { code: 'commander.unknownOption' },17 );Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 18–20why, one step back18 });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 back21 const program = createTestCommand();22 program.command('info <file>').action(() => {});Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 23why, one step back23Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 24–29why, one step back24 assert.throws(25 () => {26 program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);27 },28 { code: 'commander.unknownOption' },29 );Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 30–32why, one step back30 });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 back33 const program = createTestCommand();34 program.argument('[file]').action(() => {});Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 35why, one step back35Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 36–41why, one step back36 assert.throws(37 () => {38 program.parse(['node', 'test', '--NONSENSE']);39 },40 { code: 'commander.unknownOption' },41 );Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 42–45why, one step back42 });4344 test('when specify unknown option with program argument and action handler then error', () => {45 // Regression test from #965Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 46–47why, one step back46 const program = createTestCommand();47 program.argument('[file]').action(() => {});Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 48why, one step back48Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 49–54why, one step back49 assert.throws(50 () => {51 program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);52 },53 { code: 'commander.unknownOption' },54 );Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 55–57why, one step back55 });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 back58 const program = createTestCommand();59 assert.throws(60 () => {61 program.parse(['node', 'test', '--NONSENSE']);62 },63 { code: 'commander.unknownOption' },64 );Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 65–67why, one step back65 });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 back68 const program = createTestCommand();Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 69–70why, one step back69 program.command('sub');70Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 71–76why, one step back71 assert.throws(72 () => {73 program.parse(['--NONSENSE', 'sub'], { from: 'user' });74 },75 { code: 'commander.unknownOption' },76 );Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 77–78why, one step back77 });78});