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 fileTake it
1234567891011121314151617181920212223242526272829303132333435const commander = require('../');
test('when no arguments then asterisk action not called', () => { const mockAction = jest.fn(); const program = new commander.Command(); program .command('install') .action(mockAction); program.parse(['node', 'test']); expect(mockAction).not.toHaveBeenCalled();});
test('when recognised command then asterisk action not called', () => { const mockAction = jest.fn(); const program = new commander.Command(); program .command('install') .action(() => { }); program .action(mockAction); program.parse(['node', 'test', 'install']); expect(mockAction).not.toHaveBeenCalled();});
test('when unrecognised command/argument then asterisk action called', () => { const mockAction = jest.fn(); const program = new commander.Command(); program .command('install'); program .action(mockAction); program.parse(['node', 'test', 'unrecognised-command']); expect(mockAction).toHaveBeenCalled();});