Skip to content

Commit

Permalink
test: re-add test case from #740
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Oct 29, 2023
1 parent 9368c05 commit c16ad6a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/cron.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,29 @@ describe('cron', () => {
job.stop();
expect(callback).toHaveBeenCalledTimes(1);
});

it('should create recurring job, setTime with actual date, start and run once (#739)', () => {
const callback = jest.fn();
const clock = sinon.useFakeTimers();

const job = new CronJob('0 0 20 * * *', callback);

const startDate = new Date(Date.now() + 5000);
job.setTime(new CronTime(startDate));

job.start();

clock.tick(5000);

expect(callback).toHaveBeenCalledTimes(1);

clock.tick(60000);

clock.restore();

expect(callback).toHaveBeenCalledTimes(1);
expect(job.running).toBe(false);
});
});

describe('nextDate(s)', () => {
Expand Down

0 comments on commit c16ad6a

Please sign in to comment.