|
|
|
@ -20,15 +20,16 @@ describe('CommandAbstract', () => { |
|
|
|
const result = command.callRun(editor); |
|
|
|
const options = {}; |
|
|
|
const resOptions = { options, id: command.id, result: returnValue }; |
|
|
|
expect(triggerSpy.mock.calls.length).toBe(6); |
|
|
|
const resCallOptions = { ...resOptions, type: 'run' }; |
|
|
|
|
|
|
|
expect(triggerSpy.mock.calls.length).toBe(5); |
|
|
|
expect(triggerSpy.mock.calls[0]).toEqual([`${CommandsEvents.runBeforeCommand}test`, { options }]); |
|
|
|
expect(triggerSpy.mock.calls[1]).toEqual(['run:test:before', options]); |
|
|
|
expect(triggerSpy.mock.calls[2]).toEqual([`${CommandsEvents.runCommand}test`, resOptions]); |
|
|
|
expect(triggerSpy.mock.calls[1]).toEqual([`${CommandsEvents.runCommand}test`, resOptions]); |
|
|
|
expect(triggerSpy.mock.calls[2]).toEqual([`${CommandsEvents.callCommand}test`, resCallOptions]); |
|
|
|
expect(triggerSpy.mock.calls[3]).toEqual([CommandsEvents.run, resOptions]); |
|
|
|
expect(triggerSpy.mock.calls[4]).toEqual(['run:test', returnValue, options]); |
|
|
|
expect(triggerSpy.mock.calls[5]).toEqual(['run', 'test', returnValue, options]); |
|
|
|
expect(triggerSpy.mock.calls[4]).toEqual([CommandsEvents.call, resCallOptions]); |
|
|
|
|
|
|
|
expect(runSpy).toBeCalledTimes(1); |
|
|
|
expect(runSpy).toHaveBeenCalledTimes(1); |
|
|
|
expect(result).toEqual(returnValue); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -40,13 +41,11 @@ describe('CommandAbstract', () => { |
|
|
|
runSpy.mockReturnValue(returnValue as any); |
|
|
|
const result = command.callRun(editor, options); |
|
|
|
|
|
|
|
expect(triggerSpy.mock.calls.length).toBe(4); |
|
|
|
expect(triggerSpy.mock.calls.length).toBe(2); |
|
|
|
expect(triggerSpy.mock.calls[0]).toEqual([`${CommandsEvents.runBeforeCommand}test`, { options }]); |
|
|
|
expect(triggerSpy.mock.calls[1]).toEqual(['run:test:before', options]); |
|
|
|
expect(triggerSpy.mock.calls[2]).toEqual([`${CommandsEvents.abort}test`, { options }]); |
|
|
|
expect(triggerSpy.mock.calls[3]).toEqual(['abort:test', options]); |
|
|
|
expect(triggerSpy.mock.calls[1]).toEqual([`${CommandsEvents.abort}test`, { options }]); |
|
|
|
|
|
|
|
expect(runSpy).toBeCalledTimes(0); |
|
|
|
expect(runSpy).toHaveBeenCalledTimes(0); |
|
|
|
expect(result).toEqual(undefined); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -58,16 +57,16 @@ describe('CommandAbstract', () => { |
|
|
|
const result = command.callStop(editor); |
|
|
|
const options = {}; |
|
|
|
const resOptions = { options, id: command.id, result: returnValue }; |
|
|
|
const resCallOptions = { ...resOptions, type: 'stop' }; |
|
|
|
|
|
|
|
expect(triggerSpy.mock.calls.length).toBe(6); |
|
|
|
expect(triggerSpy.mock.calls.length).toBe(5); |
|
|
|
expect(triggerSpy.mock.calls[0]).toEqual([`${CommandsEvents.stopBeforeCommand}test`, { options }]); |
|
|
|
expect(triggerSpy.mock.calls[1]).toEqual(['stop:test:before', options]); |
|
|
|
expect(triggerSpy.mock.calls[2]).toEqual([`${CommandsEvents.stopCommand}test`, resOptions]); |
|
|
|
expect(triggerSpy.mock.calls[1]).toEqual([`${CommandsEvents.stopCommand}test`, resOptions]); |
|
|
|
expect(triggerSpy.mock.calls[2]).toEqual([`${CommandsEvents.callCommand}test`, resCallOptions]); |
|
|
|
expect(triggerSpy.mock.calls[3]).toEqual([CommandsEvents.stop, resOptions]); |
|
|
|
expect(triggerSpy.mock.calls[4]).toEqual(['stop:test', returnValue, options]); |
|
|
|
expect(triggerSpy.mock.calls[5]).toEqual(['stop', 'test', returnValue, options]); |
|
|
|
expect(triggerSpy.mock.calls[4]).toEqual([CommandsEvents.call, resCallOptions]); |
|
|
|
|
|
|
|
expect(runSpy).toBeCalledTimes(1); |
|
|
|
expect(runSpy).toHaveBeenCalledTimes(1); |
|
|
|
expect(result).toEqual(returnValue); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|