Skip to content
Myr

command.option-misuse.test.js

This file

Path

tests/command.option-misuse.test.js

22 lines · 648 bytes · JavaScript

Last changed by

Add test for Option passed to wrong routines (#1729)John Geebefore adoption1bab84c

History of this file

Take it

Add test for Option passed to wrong routines (#1729)John Geebefore adoption1bab84c

lines 1–22why, one step back
1const { Command, Option } = require('../');
23// It is a reasonable and easy mistake to pass Option to .option(). Detect this4// and offer advice.56const expectedMessage = 'To add an Option object use addOption() instead of option() or requiredOption()';78test('when pass Option to .option() then throw', () => {9 const program = new Command();1011 expect(() => {12 program.option(new Option('-d, debug'));13 }).toThrow(expectedMessage);14});1516test('when pass Option to .requiredOption() then throw', () => {17 const program = new Command();1819 expect(() => {20 program.requiredOption(new Option('-d, debug'));21 }).toThrow(expectedMessage);22});