Skip to content

Commit

Permalink
feat: add ability to get if queue is paused or not
Browse files Browse the repository at this point in the history
  • Loading branch information
ersoma authored and manast committed Dec 16, 2020
1 parent 49fe957 commit e98b7d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/classes/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ export class Queue<
this.emit('resumed');
}

async isPaused() {
const client = await this.client;
const pausedKeyExists = await client.hexists(this.keys.meta, 'paused');
return pausedKeyExists === 1;
}

async getRepeatableJobs(start?: number, end?: number, asc?: boolean) {
return (await this.repeat).getRepeatableJobs(start, end, asc);
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/test_pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,14 @@ describe('Pause', function() {
});
});
});

it('gets the right response from isPaused', async () => {
await queue.pause();
const isPausedQueuePaused = await queue.isPaused();
expect(isPausedQueuePaused).to.be.true;

await queue.resume();
const isResumedQueuePaused = await queue.isPaused();
expect(isResumedQueuePaused).to.be.false;
});
});

0 comments on commit e98b7d8

Please sign in to comment.