Skip to content
Myr

command.asterisk.test.js

This file

Path

tests/command.asterisk.test.js

34 lines · 984 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–34why, one step back
1const commander = require('../');
23test('when no arguments then asterisk action not called', () => {4 const mockAction = jest.fn();5 const program = new commander.Command();6 program7 .command('install')8 .action(mockAction);9 program.parse(['node', 'test']);10 expect(mockAction).not.toHaveBeenCalled();11});1213test('when recognised command then asterisk action not called', () => {14 const mockAction = jest.fn();15 const program = new commander.Command();16 program17 .command('install')18 .action(() => { });19 program20 .action(mockAction);21 program.parse(['node', 'test', 'install']);22 expect(mockAction).not.toHaveBeenCalled();23});2425test('when unrecognised command/argument then asterisk action called', () => {26 const mockAction = jest.fn();27 const program = new commander.Command();28 program29 .command('install');30 program31 .action(mockAction);32 program.parse(['node', 'test', 'unrecognised-command']);33 expect(mockAction).toHaveBeenCalled();34});