Skip to content

Commit

Permalink
test: 7 attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Dec 5, 2024
1 parent 6d75103 commit 24d1140
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions tests/test_job_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1187,18 +1187,24 @@ describe('Job Scheduler', function () {
const date = new Date('2017-02-02 7:21:42');
this.clock.setSystemTime(date);

const nextTick = () => {
this.clock.tick(ONE_DAY * 31);
const nextTick = (milliseconds?: number) => {
this.clock.tick(milliseconds || ONE_DAY * 31);
};

const worker = new Worker(queueName, async () => {}, {
autorun: false,
connection,
prefix,
});
const worker = new Worker(
queueName,
async () => {
nextTick();
},
{
autorun: false,
connection,
prefix,
},
);
const delayStub = sinon.stub(worker, 'delay').callsFake(async () => {});

let counter = 25;
let counter = 5;
let prev: Job;
const completing = new Promise<void>((resolve, reject) => {
worker.on('completed', async job => {
Expand All @@ -1218,7 +1224,6 @@ describe('Job Scheduler', function () {
if (counter == 0) {
resolve();
}
nextTick();
} catch (error) {
console.log(error);
reject(error);
Expand All @@ -1228,8 +1233,11 @@ describe('Job Scheduler', function () {

worker.run();

await queue.upsertJobScheduler('repeat', { pattern: '25 9 7 * *' });
nextTick();
await queue.upsertJobScheduler('repeat', {
pattern: '25 9 7 * *',
endDate: new Date('2017-06-12T14:00:00.000Z').getTime(),
});
nextTick(ONE_DAY * 6);

await completing;
await worker.close();
Expand Down

0 comments on commit 24d1140

Please sign in to comment.