|
| 1 | +const commander = require('../'); |
| 2 | + |
| 3 | +// 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). |
| 5 | + |
| 6 | +describe('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 | + }); |
| 12 | + |
| 13 | + 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 | + }); |
| 20 | + |
| 21 | + 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 | + }); |
| 28 | + |
| 29 | + 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 | +}); |
0 commit comments