Skip to content

Commit b074bad

Browse files
committed
chore: wip
1 parent 8e1e3b3 commit b074bad

15 files changed

Lines changed: 323 additions & 316 deletions

test/flow.test.ts

Lines changed: 96 additions & 96 deletions
Large diffs are not rendered by default.

test/getters.test.ts

Lines changed: 102 additions & 95 deletions
Large diffs are not rendered by default.

test/job.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ describe('Job', () => {
5858

5959
it('saves the job in redis', async () => {
6060
const storedJob = await Job.fromId(queue, job.id)
61-
expect(storedJob).to.have.property('id')
62-
expect(storedJob).to.have.property('data')
61+
expect(storedJob).toHaveProperty('id')
62+
expect(storedJob).toHaveProperty('data')
6363

6464
expect(storedJob.data.foo).toBe('bar')
6565
expect(storedJob.opts).to.be.an('object')
@@ -88,7 +88,7 @@ describe('Job', () => {
8888
const opts = { sizeLimit: 20 }
8989
const createdJob = await Job.create(queue, 'test', data, opts)
9090
expect(createdJob).to.not.be.null
91-
expect(createdJob).to.have.property('opts')
91+
expect(createdJob).toHaveProperty('opts')
9292
expect(createdJob.opts.sizeLimit).toBe(20)
9393
})
9494

@@ -208,17 +208,17 @@ describe('Job', () => {
208208
const json = JSON.stringify(job)
209209
const parsed = JSON.parse(json)
210210
expect(parsed).to.have.deep.property('data', data)
211-
expect(parsed).to.have.property('name', 'test')
212-
expect(parsed).to.have.property('returnvalue', 1)
213-
expect(parsed).to.have.property('progress', 20)
211+
expect(parsed).toHaveProperty('name', 'test')
212+
expect(parsed).toHaveProperty('returnvalue', 1)
213+
expect(parsed).toHaveProperty('progress', 20)
214214
})
215215

216216
it('omits the queue property to avoid a circular json error on node 8', async () => {
217217
const data = { foo: 'bar' }
218218
const job = await Job.create(queue, 'test', data)
219219
const json = JSON.stringify(job)
220220
const parsed = JSON.parse(json)
221-
expect(parsed).not.to.have.property('queue')
221+
expect(parsed).not.toHaveProperty('queue')
222222
})
223223

224224
it('should correctly handle zero passed as data', async () => {
@@ -677,7 +677,7 @@ describe('Job', () => {
677677
const job = (await parentWorker.getNextJob(token)) as Job
678678
const { unprocessed } = await parent.getDependencies()
679679

680-
expect(unprocessed).to.have.length(2)
680+
expect(unprocessed).toHaveLength(2)
681681

682682
const isActive = await job.isActive()
683683
expect(isActive).toBe(true)
@@ -718,7 +718,7 @@ describe('Job', () => {
718718
expect(isFailed2).toBe(true)
719719
expect(job.stacktrace).not.be.equal(null)
720720
expect(job.stacktrace.length).toBe(1)
721-
expect(job.stacktrace[0]).to.include('test_job.ts')
721+
expect(job.stacktrace[0]).toInclude('test_job.ts')
722722
await worker.close()
723723
})
724724

@@ -736,7 +736,7 @@ describe('Job', () => {
736736
expect(isFailed2).toBe(true)
737737
expect(job.stacktrace).not.be.equal(null)
738738
expect(job.stacktrace.length).toBe(1)
739-
expect(job.stacktrace[0]).to.include('test_job.ts')
739+
expect(job.stacktrace[0]).toInclude('test_job.ts')
740740
await worker.close()
741741
})
742742
})

test/job_scheduler.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('Job Scheduler', function () {
161161

162162
const delayed = await queue.getDelayed()
163163

164-
expect(delayed).to.have.length(0)
164+
expect(delayed).toHaveLength(0)
165165
expect(processed).toBe(10)
166166

167167
await worker.close()
@@ -182,7 +182,7 @@ describe('Job Scheduler', function () {
182182
expect(count).toBe(3)
183183

184184
const delayed = await queue.getDelayed()
185-
expect(delayed).to.have.length(3)
185+
expect(delayed).toHaveLength(3)
186186

187187
const jobSchedulersCount = await queue.getJobSchedulersCount()
188188
expect(jobSchedulersCount).toBe(3)
@@ -549,7 +549,7 @@ describe('Job Scheduler', function () {
549549
expect(repeatableJobs.length).toBe(1)
550550

551551
const delayed = await queue.getDelayed()
552-
expect(delayed).to.have.length(1)
552+
expect(delayed).toHaveLength(1)
553553
})
554554
})
555555

@@ -1772,7 +1772,7 @@ describe('Job Scheduler', function () {
17721772
const count = await queue.count()
17731773

17741774
expect(count).toBe(1)
1775-
expect(configs).to.have.length(1)
1775+
expect(configs).toHaveLength(1)
17761776
expect(jobs.length).toBe(2)
17771777
expect(jobs[0]!.id).toBe(jobs[1]!.id)
17781778
})
@@ -1812,7 +1812,7 @@ describe('Job Scheduler', function () {
18121812
const count = await queue.count()
18131813

18141814
expect(count).toBe(1)
1815-
expect(configs).to.have.length(1)
1815+
expect(configs).toHaveLength(1)
18161816
await worker.close()
18171817
})
18181818
})
@@ -1879,7 +1879,7 @@ describe('Job Scheduler', function () {
18791879
expect(delayedCount1).toBe(1)
18801880
const job = await queue.getJob(createdJob!.id!)
18811881
const repeatableJobs = await queue.getRepeatableJobs()
1882-
expect(repeatableJobs).to.have.length(1)
1882+
expect(repeatableJobs).toHaveLength(1)
18831883
const existBeforeRemoval = await client.exists(
18841884
`${prefix}:${queue.name}:repeat:${createdJob!.repeatJobKey!}`,
18851885
)
@@ -1896,7 +1896,7 @@ describe('Job Scheduler', function () {
18961896
expect(job!.repeatJobKey).to.not.be.undefined
18971897
expect(removed).toBeTrue()
18981898
const repeatableJobsAfterRemove = await queue.getRepeatableJobs()
1899-
expect(repeatableJobsAfterRemove).to.have.length(0)
1899+
expect(repeatableJobsAfterRemove).toHaveLength(0)
19001900
})
19011901

19021902
describe('when repeatable job does not exist', () => {
@@ -1905,7 +1905,7 @@ describe('Job Scheduler', function () {
19051905

19061906
await queue.upsertJobScheduler('remove', repeat)
19071907
const repeatableJobs = await queue.getJobSchedulers()
1908-
expect(repeatableJobs).to.have.length(1)
1908+
expect(repeatableJobs).toHaveLength(1)
19091909
const removed = await queue.removeJobScheduler(repeatableJobs[0].key)
19101910
expect(removed).toBeTrue()
19111911
const removed2 = await queue.removeJobScheduler(repeatableJobs[0].key)
@@ -1967,7 +1967,7 @@ describe('Job Scheduler', function () {
19671967

19681968
const count = await queue.count()
19691969
expect(count).toBe(1)
1970-
expect(jobSchedulers).to.have.length(1)
1970+
expect(jobSchedulers).toHaveLength(1)
19711971

19721972
expect(jobSchedulers[0]).to.deep.equal({
19731973
iterationCount: 2,
@@ -2255,20 +2255,20 @@ describe('Job Scheduler', function () {
22552255
this.clock.tick(nextTick)
22562256

22572257
let jobs = await queue.getJobSchedulers()
2258-
expect(jobs).to.have.length(1)
2258+
expect(jobs).toHaveLength(1)
22592259

22602260
let waitingJobs = await queue.getWaiting()
2261-
expect(waitingJobs).to.have.length(1)
2261+
expect(waitingJobs).toHaveLength(1)
22622262

22632263
await queue.upsertJobScheduler(key, {
22642264
every: 35_160,
22652265
})
22662266

22672267
jobs = await queue.getJobSchedulers()
2268-
expect(jobs).to.have.length(1)
2268+
expect(jobs).toHaveLength(1)
22692269

22702270
waitingJobs = await queue.getWaiting()
2271-
expect(waitingJobs).to.have.length(1)
2271+
expect(waitingJobs).toHaveLength(1)
22722272
})
22732273
})
22742274

@@ -2292,10 +2292,10 @@ describe('Job Scheduler', function () {
22922292
this.clock.tick(nextTick)
22932293

22942294
let jobs = await queue.getJobSchedulers()
2295-
expect(jobs).to.have.length(1)
2295+
expect(jobs).toHaveLength(1)
22962296

22972297
let delayedJobs = await queue.getDelayed()
2298-
expect(delayedJobs).to.have.length(1)
2298+
expect(delayedJobs).toHaveLength(1)
22992299

23002300
await queue.upsertJobScheduler(
23012301
key,
@@ -2306,10 +2306,10 @@ describe('Job Scheduler', function () {
23062306
)
23072307

23082308
jobs = await queue.getJobSchedulers()
2309-
expect(jobs).to.have.length(1)
2309+
expect(jobs).toHaveLength(1)
23102310

23112311
delayedJobs = await queue.getDelayed()
2312-
expect(delayedJobs).to.have.length(1)
2312+
expect(delayedJobs).toHaveLength(1)
23132313

23142314
expect(delayedJobs[0].name).toBe('test2')
23152315
expect(delayedJobs[0].data).to.deep.equal({

test/job_scheduler_stress.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('Job Scheduler Stress', function () {
8484
await worker.close()
8585

8686
const repeatableJobs = await queue.getJobSchedulers()
87-
expect(repeatableJobs).to.have.length(1)
87+
expect(repeatableJobs).toHaveLength(1)
8888

8989
const counts = await queue.getJobCounts()
9090

@@ -184,7 +184,7 @@ describe('Job Scheduler Stress', function () {
184184
await worker.close()
185185

186186
const repeatableJobs = await queue.getJobSchedulers()
187-
expect(repeatableJobs).to.have.length(1)
187+
expect(repeatableJobs).toHaveLength(1)
188188

189189
const counts = await queue.getJobCounts()
190190

test/obliterate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ describe('Obliterate', () => {
408408
)
409409

410410
const repeatableJobs = await queue.getRepeatableJobs()
411-
expect(repeatableJobs).to.have.length(1)
411+
expect(repeatableJobs).toHaveLength(1)
412412

413413
await queue.obliterate()
414414
const client = await queue.client
@@ -436,7 +436,7 @@ describe('Obliterate', () => {
436436
await queue.obliterate({ force: true })
437437

438438
const { logs } = await queue.getJobLogs(job.id!)
439-
expect(logs).to.have.length(0)
439+
expect(logs).toHaveLength(0)
440440

441441
await queueEvents.close()
442442
await worker.close()

test/pause.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ describe('Pause', () => {
5252
await queue.add('test', {}, { delay: 300 })
5353
const counts = await queue.getJobCounts('waiting', 'delayed')
5454

55-
expect(counts).to.have.property('waiting', 0)
56-
expect(counts).to.have.property('delayed', 1)
55+
expect(counts).toHaveProperty('waiting', 0)
56+
expect(counts).toHaveProperty('delayed', 1)
5757

5858
await delay(500)
5959
if (processed) {
6060
throw new Error('should not process delayed jobs in paused queue.')
6161
}
6262
const counts2 = await queue.getJobCounts('waiting', 'paused', 'delayed')
63-
expect(counts2).to.have.property('waiting', 0)
64-
expect(counts2).to.have.property('paused', 1)
65-
expect(counts2).to.have.property('delayed', 0)
63+
expect(counts2).toHaveProperty('waiting', 0)
64+
expect(counts2).toHaveProperty('paused', 1)
65+
expect(counts2).toHaveProperty('delayed', 0)
6666

6767
await worker.close()
6868
})

test/queue.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('queues', () => {
129129

130130
for (const key of keys) {
131131
const type = key.split(':')[2]
132-
expect(['marker', 'events', 'meta', 'pc', 'id']).to.include(type)
132+
expect(['marker', 'events', 'meta', 'pc', 'id']).toInclude(type)
133133
}
134134
}).timeout(10000)
135135

@@ -163,7 +163,7 @@ describe('queues', () => {
163163
expect(keys.length).toBe(4)
164164
for (const key of keys) {
165165
const type = key.split(':')[2]
166-
expect(['events', 'meta', 'id', 'marker']).to.include(type)
166+
expect(['events', 'meta', 'id', 'marker']).toInclude(type)
167167
}
168168

169169
const countAfterEmpty = await queue.count()
@@ -197,7 +197,7 @@ describe('queues', () => {
197197
expect(keys.length).toBe(4)
198198
for (const key of keys) {
199199
const type = key.split(':')[2]
200-
expect(['id', 'meta', 'marker', 'events']).to.include(type)
200+
expect(['id', 'meta', 'marker', 'events']).toInclude(type)
201201
}
202202

203203
const countAfterEmpty = await queue.count()
@@ -286,7 +286,7 @@ describe('queues', () => {
286286
expect(keys.length).toBe(4)
287287
for (const key of keys) {
288288
const type = key.split(':')[2]
289-
expect(['id', 'meta', 'events', 'marker']).to.include(type)
289+
expect(['id', 'meta', 'events', 'marker']).toInclude(type)
290290
}
291291

292292
const countAfterEmpty = await queue.count()
@@ -337,7 +337,7 @@ describe('queues', () => {
337337
expect(keys.length).toBe(4)
338338
for (const key of keys) {
339339
const type = key.split(':')[2]
340-
expect(['id', 'meta', 'events', 'marker']).to.include(type)
340+
expect(['id', 'meta', 'events', 'marker']).toInclude(type)
341341
}
342342

343343
const countAfterEmpty = await queue.count()

test/rate_limiter.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ describe('Rate Limiter', () => {
185185
await delay(500)
186186

187187
const counts = await queue.getJobCounts('paused', 'completed', 'wait')
188-
expect(counts).to.have.property('paused', numJobs - 1)
189-
expect(counts).to.have.property('completed', 1)
190-
expect(counts).to.have.property('wait', 0)
188+
expect(counts).toHaveProperty('paused', numJobs - 1)
189+
expect(counts).toHaveProperty('completed', 1)
190+
expect(counts).toHaveProperty('wait', 0)
191191

192192
await worker1.close()
193193
await worker2.close()

0 commit comments

Comments
 (0)