Skip to content
Myr

command.name.test.js

This file

Path

tests/command.name.test.js

28 lines · 932 bytes · JavaScript

Last changed by

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

History of this file

Take it

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 1–28why, one step back
1const commander = require('../');
23test('when set program name and parse then name is as assigned', () => {4 const program = new commander.Command();5 program.name('custom');6 program.parse(['node', 'test']);7 expect(program.name()).toBe('custom');8});910test('when program name not set and parse then name is found from arguments', () => {11 const program = new commander.Command();12 program.parse(['node', 'test']);13 expect(program.name()).toBe('test');14});1516test('when add command then command is named', () => {17 const program = new commander.Command();18 const subcommand = program19 .command('mycommand <file>');20 expect(subcommand.name()).toBe('mycommand');21});2223test('when set program name then name appears in help', () => {24 const program = new commander.Command();25 program.name('custom-name');26 const helpInformation = program.helpInformation();27 expect(helpInformation).toMatch(/^Usage: custom-name/);28});