command.option-misuse.test.js
This file
Path
tests/command.option-misuse.test.js
33 lines · 935 bytes · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake 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 back1import { Command, Option } from '../index.js';2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 4–7why, one step back45// It is a reasonable and easy mistake to pass Option to .option(). Detect this6// and offer advice.7Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 8–9why, one step back8const expectedMessage =9 'To add an Option object use addOption() instead of option() or requiredOption()';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 10why, one step back10Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 11–13why, one step back11describe('Command methods detect and explains misuse when incorrectly pass Option object', () => {12 test('when pass Option to .option() then throw', () => {13 const program = new Command();Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 14why, one step back14Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 15–21why, one step back15 assert.throws(16 () => {17 program.option(new Option('-d, debug'));18 },19 { message: expectedMessage },20 );21 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 22why, one step back22Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 23–24why, one step back23 test('when pass Option to .requiredOption() then throw', () => {24 const program = new Command();Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 25why, one step back25Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 26–32why, one step back26 assert.throws(27 () => {28 program.requiredOption(new Option('-d, debug'));29 },30 { message: expectedMessage },31 );32 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 33why, one step back33});