help.subcommandDescription.test.js
This file
Path
tests/help.subcommandDescription.test.js
37 lines · 1.4 KiB · JavaScript
Last changed by
Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
History of this fileTake it
Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 1–37why, one step back1const 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('subcommandDescription', () => {7 test('when program has no summary or description then empty string', () => {8 const program = new commander.Command();9 const helper = new commander.Help();10 expect(helper.subcommandDescription(program)).toEqual('');11 });1213 test('when program has summary then return summary', () => {14 const summary = 'summary';15 const program = new commander.Command();16 program.summary(summary);17 const helper = new commander.Help();18 expect(helper.subcommandDescription(program)).toEqual(summary);19 });2021 test('when program has description then return description', () => {22 const description = 'description';23 const program = new commander.Command();24 program.description(description);25 const helper = new commander.Help();26 expect(helper.subcommandDescription(program)).toEqual(description);27 });2829 test('when program has summary and description then return summary', () => {30 const summary = 'summary';31 const program = new commander.Command();32 program.summary(summary);33 program.description('description');34 const helper = new commander.Help();35 expect(helper.subcommandDescription(program)).toEqual(summary);36 });37});