Skip to content

Commit

Permalink
test: check errorHandler is called with the exception + fix case typo
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Mar 8, 2024
1 parent f06f73e commit b3902a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/cron.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ describe('cron', () => {
expect(callback).toHaveBeenCalledTimes(1);
});

it('should catch errors everytime, if errorhandler is provided', () => {
it('should catch errors everytime, if errorHandler is provided', () => {
const clock = sinon.useFakeTimers();
const errorFunc = jest.fn().mockImplementation(() => {
throw Error('Exception');
Expand All @@ -1254,15 +1254,17 @@ describe('cron', () => {
clock.tick(1000);
expect(errorFunc).toHaveBeenCalledTimes(1);
expect(handlerFunc).toHaveBeenCalledTimes(1);
expect(handlerFunc).toHaveBeenLastCalledWith(new Error('Exception'));
clock.tick(1000);
expect(errorFunc).toHaveBeenCalledTimes(2);
expect(handlerFunc).toHaveBeenCalledTimes(2);
expect(handlerFunc).toHaveBeenLastCalledWith(new Error('Exception'));

job.stop();
clock.restore();
});

it('should throw errors if errorhandler is NOT provided', () => {
it('should throw errors if errorHandler is NOT provided', () => {
const errorFunc = jest.fn().mockImplementation(() => {
throw Error('Exception');
});
Expand Down

0 comments on commit b3902a9

Please sign in to comment.