Skip to content
Myr

deprecated.test.js

This file

Path

tests/deprecated.test.js

31 lines · 1.3 KiB · JavaScript

Last changed by

Merge remote-tracking branch 'origin/develop' into release/10.xJohn Geebefore adoptione0f6173

History of this file

Take it

Enhance Option class to allow hiding help, specifying choices, and change how default value displayed in help (#1331)John Geebefore adoptiona05a8bc

lines 1–12why, one step back
1const commander = require('../');
23// Test for backwards compatible behaviour of deprecated features that don't fit in elsewhere.4// We keep deprecated features working (when not too difficult) to avoid breaking existing code5// and reduce barriers to updating to latest version of Commander.67describe('option with regular expression instead of custom processing function', () => {8 test('when option not given then value is default', () => {9 const program = new commander.Command();10 program11 .option('--cheese <type>', 'cheese type', /mild|tasty/, 'mild');12 program.parse([], { from: 'user' });

Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71

line 13why, one step back
13 expect(program.opts().cheese).toEqual('mild');

Enhance Option class to allow hiding help, specifying choices, and change how default value displayed in help (#1331)John Geebefore adoptiona05a8bc

lines 14–20why, one step back
14 });
1516 test('when argument matches regexp then value is as specified', () => {17 const program = new commander.Command();18 program19 .option('--cheese <type>', 'cheese type', /mild|tasty/, 'mild');20 program.parse(['--cheese', 'tasty'], { from: 'user' });

Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71

line 21why, one step back
21 expect(program.opts().cheese).toEqual('tasty');

Enhance Option class to allow hiding help, specifying choices, and change how default value displayed in help (#1331)John Geebefore adoptiona05a8bc

lines 22–23why, one step back
22 });
23

Merge remote-tracking branch 'origin/develop' into release/10.xJohn Geebefore adoptione0f6173

line 24why, one step back
24 test('when argument does not match regexp then value is default', () => {

Enhance Option class to allow hiding help, specifying choices, and change how default value displayed in help (#1331)John Geebefore adoptiona05a8bc

lines 25–28why, one step back
25 const program = new commander.Command();
26 program27 .option('--cheese <type>', 'cheese type', /mild|tasty/, 'mild');28 program.parse(['--cheese', 'other'], { from: 'user' });

Change to safe storage of options by default, and change action parameters (#1409)John Geebefore adoptionf76bc71

line 29why, one step back
29 expect(program.opts().cheese).toEqual('mild');

Enhance Option class to allow hiding help, specifying choices, and change how default value displayed in help (#1331)John Geebefore adoptiona05a8bc

lines 30–31why, one step back
30 });
31});