help.subcommandDescription.test.js
This file
Path
tests/help.subcommandDescription.test.js
39 lines · 1.5 KiB · JavaScript
Last changed by
Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637383940const { test, describe } = require('node:test');const assert = require('node:assert/strict');const commander = require('../');
// These are tests of the Help class, not of the Command help.// There is some overlap with the higher level Command tests (which predate Help).
describe('Help.subcommandDescription()', () => { test('when program has no summary or description then empty string', () => { const program = new commander.Command(); const helper = new commander.Help(); assert.equal(helper.subcommandDescription(program), ''); });
test('when program has summary then return summary', () => { const summary = 'summary'; const program = new commander.Command(); program.summary(summary); const helper = new commander.Help(); assert.equal(helper.subcommandDescription(program), summary); });
test('when program has description then return description', () => { const description = 'description'; const program = new commander.Command(); program.description(description); const helper = new commander.Help(); assert.equal(helper.subcommandDescription(program), description); });
test('when program has summary and description then return summary', () => { const summary = 'summary'; const program = new commander.Command(); program.summary(summary); program.description('description'); const helper = new commander.Help(); assert.equal(helper.subcommandDescription(program), summary); });});