@@ -256,27 +256,25 @@ test('Error thrown 415 from content type is null and make post request to server
256
256
257
257
test ( 'remove' , t => {
258
258
test ( 'should remove default parser' , t => {
259
- t . plan ( 2 )
259
+ t . plan ( 3 )
260
260
261
261
const fastify = Fastify ( )
262
262
const contentTypeParser = fastify [ keys . kContentTypeParser ]
263
263
264
- contentTypeParser . remove ( 'application/json' )
265
-
264
+ t . ok ( contentTypeParser . remove ( 'application/json' ) )
266
265
t . notOk ( contentTypeParser . customParsers [ 'application/json' ] )
267
266
t . notOk ( contentTypeParser . parserList . find ( parser => parser === 'application/json' ) )
268
267
} )
269
268
270
269
test ( 'should remove RegExp parser' , t => {
271
- t . plan ( 2 )
270
+ t . plan ( 3 )
272
271
273
272
const fastify = Fastify ( )
274
273
fastify . addContentTypeParser ( / ^ t e x t \/ * / , first )
275
274
276
275
const contentTypeParser = fastify [ keys . kContentTypeParser ]
277
276
278
- contentTypeParser . remove ( / ^ t e x t \/ * / )
279
-
277
+ t . ok ( contentTypeParser . remove ( / ^ t e x t \/ * / ) )
280
278
t . notOk ( contentTypeParser . customParsers [ / ^ t e x t \/ * / ] )
281
279
t . notOk ( contentTypeParser . parserRegExpList . find ( parser => parser . toString ( ) === / ^ t e x t \/ * / . toString ( ) ) )
282
280
} )
@@ -289,23 +287,22 @@ test('remove', t => {
289
287
t . throws ( ( ) => fastify [ keys . kContentTypeParser ] . remove ( 12 ) , FST_ERR_CTP_INVALID_TYPE )
290
288
} )
291
289
292
- test ( 'should not throw error if content type does not exist' , t => {
290
+ test ( 'should return false if content type does not exist' , t => {
293
291
t . plan ( 1 )
294
292
295
293
const fastify = Fastify ( )
296
294
297
- t . doesNotThrow ( ( ) => fastify [ keys . kContentTypeParser ] . remove ( 'image/png' ) )
295
+ t . notOk ( fastify [ keys . kContentTypeParser ] . remove ( 'image/png' ) )
298
296
} )
299
297
300
298
test ( 'should not remove any content type parser if content type does not exist' , t => {
301
- t . plan ( 1 )
299
+ t . plan ( 2 )
302
300
303
301
const fastify = Fastify ( )
304
302
305
303
const contentTypeParser = fastify [ keys . kContentTypeParser ]
306
304
307
- contentTypeParser . remove ( 'image/png' )
308
-
305
+ t . notOk ( contentTypeParser . remove ( 'image/png' ) )
309
306
t . same ( contentTypeParser . customParsers . size , 2 )
310
307
} )
311
308
0 commit comments