Skip to content

Commit a0d1f20

Browse files
committed
fix: standardize assertions using fail
1 parent d21dade commit a0d1f20

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

test/multipart-big-stream.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ test('should emit fileSize limitation error during streaming', async function (t
8181
res.resume()
8282
await once(res, 'end')
8383
} catch (error) {
84-
t.assert.fail(error, 'request')
84+
t.assert.ifError(error, 'request')
8585
}
8686
})

test/multipart-fileLimit.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ test('should NOT throw fileSize limitation error when consuming the stream', asy
157157
t.assert.notStrictEqual(buffer.length, fileInputLength)
158158
reply.send(new fastify.multipartErrors.FilesLimitError())
159159
} catch {
160-
t.assert.ifError('it should not throw')
160+
t.assert.fail('it should not throw')
161161
}
162162
})
163163

@@ -283,7 +283,7 @@ test('should NOT throw fileSize limitation error when throwFileSizeLimit is glob
283283
t.assert.notStrictEqual(buffer.length, fileInputLength)
284284
reply.send(new fastify.multipartErrors.FilesLimitError())
285285
} catch {
286-
t.assert.ifError('it should not throw')
286+
t.assert.fail('it should not throw')
287287
}
288288
})
289289

test/multipart-security.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ test('should use default for fileSize', async function (t) {
263263
try {
264264
await part.toBuffer()
265265
reply.send('not ok')
266-
t.assert.ok('it should throw')
266+
t.assert.fail('it should throw')
267267
} catch (error) {
268268
t.assert.ok(error)
269269
reply.send(error)
@@ -311,7 +311,7 @@ test('should use default for parts - 1000', function (t, done) {
311311
try {
312312
// eslint-disable-next-lint no-empty
313313
for await (const _ of req.parts()) { console.assert(_) }
314-
t.assert.ok('should throw on 1001')
314+
t.assert.fail('should throw on 1001')
315315
reply.code(200).send()
316316
} catch (error) {
317317
t.assert.ok(error instanceof fastify.multipartErrors.PartsLimitError)

test/multipart-update-options-type.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('Should throw RequestFileTooLargeError when throwFileSizeLimit: true for fi
2222
try {
2323
const file = await req.file({ limits: { fileSize: 1 }, throwFileSizeLimit: true })
2424
await file.toBuffer()
25-
t.assert.ok('should throw')
25+
t.assert.fail('should throw')
2626
reply.code(200).send()
2727
} catch (error) {
2828
t.assert.ok(error instanceof fastify.multipartErrors.RequestFileTooLargeError)
@@ -77,7 +77,7 @@ test('Should NOT throw RequestFileTooLargeError when throwFileSizeLimit: false f
7777
t.assert.ok('OK')
7878
reply.code(200).send()
7979
} catch {
80-
t.assert.ok('Should not throw')
80+
t.assert.fail('Should not throw')
8181
reply.code(500).send()
8282
}
8383
})
@@ -128,7 +128,7 @@ test('Should throw RequestFileTooLargeError when throwFileSizeLimit: true for fi
128128
for await (const file of files) {
129129
await file.toBuffer()
130130
}
131-
t.assert.ok('Should throw')
131+
t.assert.fail('Should throw')
132132
reply.code(200).send()
133133
} catch (error) {
134134
t.assert.ok(error instanceof fastify.multipartErrors.RequestFileTooLargeError)
@@ -185,7 +185,7 @@ test('Should NOT throw RequestFileTooLargeError when throwFileSizeLimit: false f
185185
t.assert.ok('OK')
186186
reply.code(200).send()
187187
} catch {
188-
t.assert.ok('Should not throw')
188+
t.assert.fail('Should not throw')
189189
reply.code(500).send()
190190
}
191191
})

0 commit comments

Comments
 (0)