Skip to content
Myr

help.visibleArguments.test.js

This file

Path

tests/help.visibleArguments.test.js

65 lines · 2.6 KiB · JavaScript

Last changed by

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

History of this file

Take it

Add .allowExcessArguments() and error message (#1407)John Geebefore adoption09f277a

lines 1–14why, one step back
1const commander = require('../');
23// These are tests of the Help class, not of the Command help.4// There is some overlap with the higher level Command tests (which predate Help).56describe('visibleArguments', () => {7 test('when no arguments then empty array', () => {8 const program = new commander.Command();9 const helper = new commander.Help();10 expect(helper.visibleArguments(program)).toEqual([]);11 });1213 test('when argument but no argument description then empty array', () => {14 const program = new commander.Command();

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

line 15why, one step back
15 program.argument('<file>');

Add .allowExcessArguments() and error message (#1407)John Geebefore adoption09f277a

lines 16–21why, one step back
16 const helper = new commander.Help();
17 expect(helper.visibleArguments(program)).toEqual([]);18 });1920 test('when argument and argument description then returned', () => {21 const program = new commander.Command();

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

line 22why, one step back
22 program.argument('<file>', 'file description');

Add .allowExcessArguments() and error message (#1407)John Geebefore adoption09f277a

line 23why, one step back
23 const helper = new commander.Help();

More consistent way of adding command arguments (#1490)John Geebefore adoptionb286da9

lines 24–63why, one step back
24 const visibleArguments = helper.visibleArguments(program);
25 expect(visibleArguments.length).toEqual(1);26 expect(visibleArguments[0]).toEqual(new commander.Argument('<file>', 'file description'));27 });2829 test('when argument and legacy argument description then returned', () => {30 const program = new commander.Command();31 program.argument('<file>');32 program.description('', {33 file: 'file description'34 });35 const helper = new commander.Help();36 const visibleArguments = helper.visibleArguments(program);37 expect(visibleArguments.length).toEqual(1);38 expect(visibleArguments[0]).toEqual(new commander.Argument('<file>', 'file description'));39 });4041 test('when arguments and some described then all returned', () => {42 const program = new commander.Command();43 program.argument('<file1>', 'file1 description');44 program.argument('<file2>');45 const helper = new commander.Help();46 const visibleArguments = helper.visibleArguments(program);47 expect(visibleArguments.length).toEqual(2);48 expect(visibleArguments[0]).toEqual(new commander.Argument('<file1>', 'file1 description'));49 expect(visibleArguments[1]).toEqual(new commander.Argument('<file2>'));50 });5152 test('when arguments and some legacy described then all returned', () => {53 const program = new commander.Command();54 program.argument('<file1>');55 program.argument('<file2>');56 program.description('', {57 file1: 'file1 description'58 });59 const helper = new commander.Help();60 const visibleArguments = helper.visibleArguments(program);61 expect(visibleArguments.length).toEqual(2);62 expect(visibleArguments[0]).toEqual(new commander.Argument('<file1>', 'file1 description'));63 expect(visibleArguments[1]).toEqual(new commander.Argument('<file2>'));

Add .allowExcessArguments() and error message (#1407)John Geebefore adoption09f277a

lines 64–65why, one step back
64 });
65});