Skip to content

Commit 9fb126c

Browse files
committed
chore: wip
1 parent 0e1edf7 commit 9fb126c

6 files changed

Lines changed: 44 additions & 47 deletions

File tree

test/events.test.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import type {
2-
QueueEventsListener,
3-
} from '../src/classes'
4-
import { expect } from 'chai'
5-
import { default as IORedis } from 'ioredis'
1+
import type { QueueEventsListener } from '../src/classes'
2+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from 'bun:test'
3+
import IORedis from 'ioredis'
64
import { after } from 'lodash'
7-
import { after as afterAll, before, beforeEach, describe, it } from 'mocha'
85
import { v4 } from 'uuid'
96
import {
107
FlowProducer,
@@ -23,9 +20,9 @@ describe('events', function () {
2320
let queue: Queue
2421
let queueEvents: QueueEvents
2522
let queueName: string
23+
let connection: IORedis
2624

27-
let connection
28-
before(async () => {
25+
beforeAll(async () => {
2926
connection = new IORedis(redisHost, { maxRetriesPerRequest: null })
3027
})
3128

@@ -979,7 +976,7 @@ describe('events', function () {
979976
await delay(50) // additional delay since XREAD from '$' is unstable
980977
queueEvents.on('waiting', ({ jobId }) => {
981978
expect(jobId).toBe('1')
982-
expect(state).to.be.undefined
979+
expect(state).toBeUndefined()
983980
state = 'waiting'
984981
})
985982
queueEvents.once('active', ({ jobId, prev }) => {
@@ -992,7 +989,7 @@ describe('events', function () {
992989
const completed = new Promise<void>((resolve) => {
993990
queueEvents.once('completed', async ({ jobId, returnvalue }) => {
994991
expect(jobId).toBe('1')
995-
expect(returnvalue).to.be.null
992+
expect(returnvalue).toBeNull()
996993
expect(state).toBe('active')
997994
resolve()
998995
})

test/flow.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ describe('flows', () => {
344344
const jobIdFromDebounceKey = await queue.getDebounceJobId(
345345
'debounce_id',
346346
)
347-
expect(jobIdFromDebounceKey).to.be.null
347+
expect(jobIdFromDebounceKey).toBeNull()
348348

349349
expect(debouncedCounter).toBe(1)
350350

@@ -588,8 +588,8 @@ describe('flows', () => {
588588
= await children![0].job.removeChildDependency()
589589

590590
expect(relationshipIsBroken).to.be.true
591-
expect(children![0].job.parent).to.be.undefined
592-
expect(children![0].job.parentKey).to.be.undefined
591+
expect(children![0].job.parent).toBeUndefined()
592+
expect(children![0].job.parentKey).toBeUndefined()
593593

594594
const parentState = await job.getState()
595595

@@ -657,8 +657,8 @@ describe('flows', () => {
657657
= await children![0].job.removeChildDependency()
658658

659659
expect(relationshipIsBroken).to.be.true
660-
expect(children![0].job.parent).to.be.undefined
661-
expect(children![0].job.parentKey).to.be.undefined
660+
expect(children![0].job.parent).toBeUndefined()
661+
expect(children![0].job.parentKey).toBeUndefined()
662662

663663
const parentState = await job.getState()
664664

@@ -1571,7 +1571,7 @@ describe('flows', () => {
15711571
parentWorker.on('completed', async (job: Job) => {
15721572
expect(job.finishedOn).to.be.string
15731573
const gotJob = await parentQueue.getJob(job.id)
1574-
expect(gotJob).to.be.undefined
1574+
expect(gotJob).toBeUndefined()
15751575
const counts = await parentQueue.getJobCounts('completed')
15761576
expect(counts.completed).toBe(0)
15771577
resolve()
@@ -1719,7 +1719,7 @@ describe('flows', () => {
17191719
parentWorker.on('completed', async (job: Job) => {
17201720
expect(job.finishedOn).to.be.string
17211721
const gotJob = await parentQueue.getJob(job.id)
1722-
expect(gotJob).to.be.undefined
1722+
expect(gotJob).toBeUndefined()
17231723
const counts = await parentQueue.getJobCounts('completed')
17241724
expect(counts.completed).toBe(0)
17251725
resolve()
@@ -3024,7 +3024,7 @@ describe('flows', () => {
30243024
expect(updatedGrandchildJob.failedReason).toBe('failed')
30253025

30263026
const updatedParentJob = await queue.getJob(children[1].job.id)
3027-
expect(updatedParentJob).to.be.undefined
3027+
expect(updatedParentJob).toBeUndefined()
30283028

30293029
const updatedGrandparentJob = await parentQueue.getJob(job.id)
30303030
const updatedGrandparentState = await updatedGrandparentJob.getState()
@@ -4008,10 +4008,10 @@ describe('flows', () => {
40084008
expect(children.length).to.be.greaterThanOrEqual(2)
40094009

40104010
expect(children[0].job.id).to.be.ok
4011-
expect(children[0].children).to.be.undefined
4011+
expect(children[0].children).toBeUndefined()
40124012

40134013
expect(children[1].job.id).to.be.ok
4014-
expect(children[1].children).to.be.undefined
4014+
expect(children[1].children).toBeUndefined()
40154015

40164016
await flow.close()
40174017

@@ -5135,7 +5135,7 @@ describe('flows', () => {
51355135
const childJob = await Job.fromId(queue, child.job.id!)
51365136

51375137
if (!processed.includes(child.job.id!)) {
5138-
expect(childJob).to.be.undefined
5138+
expect(childJob).toBeUndefined()
51395139
}
51405140
else {
51415141
expect(childJob).to.be.ok
@@ -5276,12 +5276,12 @@ describe('flows', () => {
52765276

52775277
const parentQueue = new Queue(parentQueueName, { connection, prefix })
52785278
const parentJob = await Job.fromId(parentQueue, tree.job.id)
5279-
expect(parentJob).to.be.undefined
5279+
expect(parentJob).toBeUndefined()
52805280

52815281
for (let i = 0; i < tree.children.length; i++) {
52825282
const child = tree.children[i]
52835283
const childJob = await Job.fromId(queue, child.job.id)
5284-
expect(childJob).to.be.undefined
5284+
expect(childJob).toBeUndefined()
52855285
}
52865286

52875287
expect(await tree.children[0].job.getState()).toBe('unknown')
@@ -5341,7 +5341,7 @@ describe('flows', () => {
53415341

53425342
const parentQueue = new Queue(parentQueueName, { connection, prefix })
53435343
const parentJob = await Job.fromId(parentQueue, tree.job.id)
5344-
expect(parentJob).to.be.undefined
5344+
expect(parentJob).toBeUndefined()
53455345

53465346
for (let i = 0; i < tree.children.length; i++) {
53475347
const child = tree.children[i]
@@ -5431,12 +5431,12 @@ describe('flows', () => {
54315431

54325432
const parentQueue = new Queue(parentQueueName, { connection, prefix })
54335433
const parentJob = await Job.fromId(parentQueue, tree.job.id)
5434-
expect(parentJob).to.be.undefined
5434+
expect(parentJob).toBeUndefined()
54355435

54365436
for (let i = 0; i < tree.children.length; i++) {
54375437
const child = tree.children[i]
54385438
const childJob = await Job.fromId(queue, child.job.id)
5439-
expect(childJob).to.be.undefined
5439+
expect(childJob).toBeUndefined()
54405440
}
54415441

54425442
const jobs = await queue.getJobCountByTypes('completed')
@@ -5538,12 +5538,12 @@ describe('flows', () => {
55385538
prefix,
55395539
})
55405540
const parentJob = await Job.fromId(parentQueue, tree.job.id)
5541-
expect(parentJob).to.be.undefined
5541+
expect(parentJob).toBeUndefined()
55425542

55435543
for (let i = 0; i < tree.children![0].children!.length; i++) {
55445544
const child = tree.children![0].children![i]
55455545
const childJob = await Job.fromId(queue, child.job.id)
5546-
expect(childJob).to.be.undefined
5546+
expect(childJob).toBeUndefined()
55475547
}
55485548

55495549
const jobs = await queue.getJobCountByTypes('completed')
@@ -5658,12 +5658,12 @@ describe('flows', () => {
56585658

56595659
const parentQueue = new Queue(parentQueueName, { connection, prefix })
56605660
const parentJob = await Job.fromId(parentQueue, tree.job.id)
5661-
expect(parentJob).to.be.undefined
5661+
expect(parentJob).toBeUndefined()
56625662

56635663
for (let i = 0; i < tree.children.length; i++) {
56645664
const child = tree.children[i]
56655665
const childJob = await Job.fromId(queue, child.job.id)
5666-
expect(childJob).to.be.undefined
5666+
expect(childJob).toBeUndefined()
56675667
}
56685668

56695669
const jobs = await queue.getJobCountByTypes('failed')

test/job_scheduler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ describe('Job Scheduler', function () {
557557
it('should return undefined', async () => {
558558
const scheduler = await queue.getJobScheduler('test')
559559

560-
expect(scheduler).to.be.undefined
560+
expect(scheduler).toBeUndefined()
561561
})
562562
})
563563

test/sandboxed_process.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('sandboxed process using child processes', () => {
110110
const retainedChild = Object.values(
111111
worker.childPool.retained,
112112
)[0]
113-
expect(retainedChild).to.be.undefined
113+
expect(retainedChild).toBeUndefined()
114114
resolve()
115115
}
116116
catch (err) {
@@ -1463,7 +1463,7 @@ function sandboxProcessTests(
14631463
const completing = new Promise<void>((resolve, reject) => {
14641464
worker.on('completed', async (job) => {
14651465
try {
1466-
expect(job!.returnvalue).to.be.undefined
1466+
expect(job!.returnvalue).toBeUndefined()
14671467
resolve()
14681468
}
14691469
catch (err) {

test/stalled_jobs.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('stalled jobs', () => {
272272
worker2.on(
273273
'failed',
274274
after(concurrency, async (job, failedReason, prev) => {
275-
expect(job).to.be.undefined
275+
expect(job).toBeUndefined()
276276
expect(prev).toBe('active')
277277
expect(failedReason.message).toBe(errorMessage)
278278
resolve()
@@ -351,7 +351,7 @@ describe('stalled jobs', () => {
351351
worker.on(
352352
'failed',
353353
after(concurrency, async (job, failedReason, prev) => {
354-
expect(job).to.be.undefined
354+
expect(job).toBeUndefined()
355355
expect(prev).toBe('active')
356356
expect(failedReason.message).toBe(errorMessage)
357357
resolve()
@@ -888,7 +888,7 @@ describe('stalled jobs', () => {
888888
worker2.on(
889889
'failed',
890890
after(concurrency, async (job, failedReason, prev) => {
891-
expect(job).to.be.undefined
891+
expect(job).toBeUndefined()
892892
const failedCount = await queue.getFailedCount()
893893
expect(failedCount).to.equal(2)
894894

test/worker.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,16 +2004,16 @@ describe('workers', function () {
20042004

20052005
await job.retry()
20062006

2007-
expect(job.failedReason).to.be.null
2008-
expect(job.processedOn).to.be.null
2009-
expect(job.finishedOn).to.be.null
2010-
expect(job.returnvalue).to.be.null
2007+
expect(job.failedReason).toBeNull()
2008+
expect(job.processedOn).toBeNull()
2009+
expect(job.finishedOn).toBeNull()
2010+
expect(job.returnvalue).toBeNull()
20112011

20122012
const updatedJob = await queue.getJob(job.id)
2013-
expect(updatedJob.failedReason).to.be.undefined
2014-
expect(updatedJob.processedOn).to.be.undefined
2015-
expect(updatedJob.finishedOn).to.be.undefined
2016-
expect(updatedJob.returnvalue).to.be.null
2013+
expect(updatedJob.failedReason).toBeUndefined()
2014+
expect(updatedJob.processedOn).toBeUndefined()
2015+
expect(updatedJob.finishedOn).toBeUndefined()
2016+
expect(updatedJob.returnvalue).toBeNull()
20172017

20182018
await worker.resume()
20192019
})
@@ -2643,7 +2643,7 @@ describe('workers', function () {
26432643

26442644
worker.on('failed', async () => {
26452645
const token = await client.get(`${prefix}:${queueName}:${job.id}:lock`)
2646-
expect(token).to.be.null
2646+
expect(token).toBeNull()
26472647
})
26482648

26492649
const workerCompleted = new Promise<void>((resolve) => {
@@ -2656,7 +2656,7 @@ describe('workers', function () {
26562656

26572657
const token = await client.get(`${prefix}:${queueName}:${job.id}:lock`)
26582658

2659-
expect(token).to.be.null
2659+
expect(token).toBeNull()
26602660

26612661
await worker.close()
26622662
})
@@ -4289,7 +4289,7 @@ describe('workers', function () {
42894289
const token = await client.get(
42904290
`${prefix}:${queueName}:${parent.id}:lock`,
42914291
)
4292-
expect(token).to.be.null
4292+
expect(token).toBeNull()
42934293
expect(processed2).to.deep.equal({
42944294
[`${prefix}:${queueName}:${child1.id}`]: 'return value1',
42954295
})

0 commit comments

Comments
 (0)