Skip to content

Commit

Permalink
test: add test case for #598 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox authored and intcreator committed Apr 22, 2023
1 parent f0d5d3f commit 4322ef2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/cron.test.js
Expand Up @@ -864,6 +864,26 @@ 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);

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 4322ef2

Please sign in to comment.