From 028adf430bb01fdc9e7633d19768d9f9bcf198de Mon Sep 17 00:00:00 2001 From: Simon Tretter Date: Wed, 21 Oct 2020 23:10:36 +0200 Subject: [PATCH] test: fix eslint (#7) * test: fix eslint * test: rewrite test for prio --- test/job.test.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/job.test.ts b/test/job.test.ts index dfd0b88..c73b314 100644 --- a/test/job.test.ts +++ b/test/job.test.ts @@ -1089,21 +1089,21 @@ describe('Job', () => { // Inspired by tests added by @lushc here: // const now = new Date(); - const results: number[] = []; agenda.define('priority', (_job, cb) => setTimeout(cb, 10), { concurrency: 1 }); - const checkResultsPromise = new Promise(resolve => + const checkResultsPromise = new Promise(resolve => { + const results: number[] = []; + agenda.on('start:priority', job => { results.push(job.attrs.priority); if (results.length !== 3) { return; } - expect(results).to.eql([10, 0, -10]); - resolve(); - }) - ); + resolve(results); + }); + }); console.log('1'); await Promise.all([ @@ -1115,10 +1115,13 @@ describe('Job', () => { await agenda.start(); console.log('3'); try { - await Promise.race([ + const results = await Promise.race([ checkResultsPromise, + // eslint-disable-next-line prefer-promise-reject-errors new Promise((_, reject) => setTimeout(() => reject(`not processed`), 2000)) ]); + expect(results).to.eql([10, 0, -10]); + console.log('4'); } catch (err) { console.log('stats', JSON.stringify(await agenda.getRunningStats(), undefined, 3));