command.usage.test.js
This file
Path
tests/command.usage.test.js
46 lines · 1.4 KiB · JavaScript
Last changed by
Parse rework for nested commands (#1149)John Geebefore adoption1345f98
History of this fileTake it
Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 1–5why, one step back1const commander = require('../');23test('when default usage and check program help then starts with default usage', () => {4 const program = new commander.Command();5Parse rework for nested commands (#1149)John Geebefore adoption1345f98
line 6why, one step back6 program.name('test');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 7–17why, one step back7 const helpInformation = program.helpInformation();89 expect(helpInformation).toMatch(new RegExp('^Usage: test \\[options\\]'));10});1112test('when custom usage and check program help then starts with custom usage', () => {13 const myUsage = 'custom';14 const program = new commander.Command();15 program16 .usage(myUsage);17Parse rework for nested commands (#1149)John Geebefore adoption1345f98
line 18why, one step back18 program.name('test');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 19–28why, one step back19 const helpInformation = program.helpInformation();2021 expect(helpInformation).toMatch(new RegExp(`^Usage: test ${myUsage}`));22});2324test('when default usage and check subcommand help then starts with default usage including program name', () => {25 const program = new commander.Command();26 const subCommand = program27 .command('info');28Parse rework for nested commands (#1149)John Geebefore adoption1345f98
line 29why, one step back29 program.name('test');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 30–41why, one step back30 const helpInformation = subCommand.helpInformation();3132 expect(helpInformation).toMatch(new RegExp('^Usage: test info \\[options\\]'));33});3435test('when custom usage and check subcommand help then starts with custom usage including program name', () => {36 const myUsage = 'custom';37 const program = new commander.Command();38 const subCommand = program39 .command('info')40 .usage(myUsage);41Parse rework for nested commands (#1149)John Geebefore adoption1345f98
line 42why, one step back42 program.name('test');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 43–46why, one step back43 const helpInformation = subCommand.helpInformation();4445 expect(helpInformation).toMatch(new RegExp(`^Usage: test info ${myUsage}`));46});