diff --git a/src/classes/queue-events.ts b/src/classes/queue-events.ts index 450b26d2ce..e6a8e12e62 100644 --- a/src/classes/queue-events.ts +++ b/src/classes/queue-events.ts @@ -4,6 +4,10 @@ import { QueueBase } from './queue-base'; import { StreamReadRaw } from '../interfaces/redis-streams'; export declare interface QueueEvents { + on( + event: 'active', + listener: (args: { jobId: string }, prev?: string) => void, + ): this; on( event: 'waiting', listener: (args: { jobId: string }, id: string) => void, diff --git a/src/test/test_delay.ts b/src/test/test_delay.ts index 1dbf7b2b45..fc8f9baa42 100644 --- a/src/test/test_delay.ts +++ b/src/test/test_delay.ts @@ -1,12 +1,12 @@ -import { Queue, Job } from '@src/classes'; +import { Queue, Job } from '../classes'; import { describe, beforeEach, it } from 'mocha'; import { expect } from 'chai'; import * as IORedis from 'ioredis'; import { v4 } from 'uuid'; -import { Worker } from '@src/classes/worker'; -import { QueueEvents } from '@src/classes/queue-events'; -import { QueueScheduler } from '@src/classes/queue-scheduler'; -import { removeAllQueueData } from '@src/utils'; +import { Worker } from '../classes/worker'; +import { QueueEvents } from '../classes/queue-events'; +import { QueueScheduler } from '../classes/queue-scheduler'; +import { removeAllQueueData } from '../utils'; describe('Delayed jobs', function() { this.timeout(15000); diff --git a/src/test/test_events.ts b/src/test/test_events.ts index 9b475188ad..9e77412711 100644 --- a/src/test/test_events.ts +++ b/src/test/test_events.ts @@ -108,17 +108,22 @@ describe('events', function() { let state: string; await delay(50); // additional delay since XREAD from '$' is unstable - queueEvents.on('waiting', function() { + queueEvents.on('waiting', function({ jobId }) { + expect(jobId).to.be.equal('1'); expect(state).to.be.undefined; state = 'waiting'; }); - queueEvents.once('active', function() { + queueEvents.once('active', function({ jobId, prev }) { + expect(jobId).to.be.equal('1'); + expect(prev).to.be.equal('waiting'); expect(state).to.be.equal('waiting'); state = 'active'; }); const completed = new Promise(resolve => { - queueEvents.once('completed', async function() { + queueEvents.once('completed', async function({ jobId, returnvalue }) { + expect(jobId).to.be.equal('1'); + expect(returnvalue).to.be.null; expect(state).to.be.equal('active'); resolve(); });