Skip to content

Commit

Permalink
fix(test): fix timeout check
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed Oct 20, 2020
1 parent 3fe9a6d commit e92cd85
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,14 +837,15 @@ describe('Job', () => {
});

it('runs a one-time job after its lock expires', async () => {
let runCount = 0;
const processorPromise = new Promise(resolve => {
let runCount = 0;

const processorPromise = new Promise(resolve =>
agenda.define(
'lock job',
async _job => {
runCount++;
if (runCount === 1) {
// this should time out
await new Promise(longResolve => setTimeout(longResolve, 1000));
} else {
resolve(runCount);
Expand All @@ -853,14 +854,14 @@ describe('Job', () => {
{
lockLifetime: 50
}
)
);
);
});

let errorHasBeenThrown;
agenda.on('error', err => {
errorHasBeenThrown = err;
});
agenda.processEvery(50);
agenda.processEvery(25);
await agenda.start();
agenda.now('lock job', {
i: 1
Expand Down

0 comments on commit e92cd85

Please sign in to comment.