Skip to content

Commit

Permalink
test: add test case for kelektiv#598 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Apr 14, 2023
1 parent 3080b66 commit 33440eb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/cron.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,27 @@ describe('cron', () => {
expect(callback).toHaveBeenCalledTimes(3);
});

it('should start, stop, change time, not start again', () => {
const callback = jest.fn();
const clock = sinon.useFakeTimers();

const job = new cron.CronJob('* * * * * *', callback);

job.start();
clock.tick(1000);

job.stop();
const time = cron.time('*/2 * * * * *');
job.setTime(time);
job.start();

clock.tick(4000);

clock.restore();
job.stop();
expect(callback).toHaveBeenCalledTimes(1);
});

it('should setTime with invalid object', () => {
const callback = jest.fn();
const job = new cron.CronJob('* * * * * *', callback);
Expand Down

0 comments on commit 33440eb

Please sign in to comment.