Skip to content
Myr

help.argumentDescription.test.js

This file

Path

tests/help.argumentDescription.test.js

36 lines · 1.6 KiB · JavaScript

Last changed by

Choices for arguments (#1525)John Geebefore adoption708527e

History of this file

Take it

Extend .argument() to add default value and custom parse for command-argument (#1508)John Geebefore adoptionf99d6fa

lines 1–29why, one step back
1const commander = require('../');
23// These are tests of the Help class, not of the Command help.45describe('argumentDescription', () => {6 test('when argument has no description then empty string', () => {7 const argument = new commander.Argument('[n]');8 const helper = new commander.Help();9 expect(helper.argumentDescription(argument)).toEqual('');10 });1112 test('when argument has description then return description', () => {13 const description = 'description';14 const argument = new commander.Argument('[n]', description);15 const helper = new commander.Help();16 expect(helper.argumentDescription(argument)).toEqual(description);17 });1819 test('when argument has default value then return description and default value', () => {20 const argument = new commander.Argument('[n]', 'description').default('default');21 const helper = new commander.Help();22 expect(helper.argumentDescription(argument)).toEqual('description (default: "default")');23 });2425 test('when argument has default value description then return description and custom default description', () => {26 const argument = new commander.Argument('[n]', 'description').default('default value', 'custom');27 const helper = new commander.Help();28 expect(helper.argumentDescription(argument)).toEqual('description (default: custom)');29 });

Choices for arguments (#1525)John Geebefore adoption708527e

lines 30–35why, one step back
30
31 test('when an argument has default value and no description then still return default value', () => {32 const argument = new commander.Argument('[n]').default('default');33 const helper = new commander.Help();34 expect(helper.argumentDescription(argument)).toEqual('(default: "default")');35 });

Extend .argument() to add default value and custom parse for command-argument (#1508)John Geebefore adoptionf99d6fa

line 36why, one step back
36});