Skip to content

Commit

Permalink
test(repeatable): add case when promoting a repeatable job (#2768) ref
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Sep 12, 2024
1 parent 44a2d62 commit ce1b22e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,37 @@ describe('Job', function () {
);
});

describe('when a repeatable job is promoted', () => {
it('add next delayed job after promoted job completion', async () => {
const job = await queue.add(
'test',
{ foo: 'bar' },
{ repeat: {
pattern: '0 0 7 * * *'
}, },
);
const isDelayed = await job.isDelayed();
expect(isDelayed).to.be.equal(true);
await job.promote();
expect(job.delay).to.be.equal(0);

const worker = new Worker(queueName, null, { connection, prefix });

const currentJob1 = (await worker.getNextJob('token')) as Job;
expect(currentJob1).to.not.be.undefined;

await currentJob1.moveToCompleted('succeeded', 'token', true);

const delayedCount = await queue.getDelayedCount();
expect(delayedCount).to.be.equal(1);

const isDelayedAfterPromote = await job.isDelayed();
expect(isDelayedAfterPromote).to.be.equal(false);
const isCompleted = await job.isCompleted();
expect(isCompleted).to.be.equal(true);
});
});

describe('when queue is paused', () => {
it('should promote delayed job to the right queue', async () => {
await queue.add('normal', { foo: 'bar' });
Expand Down

0 comments on commit ce1b22e

Please sign in to comment.