@@ -253,6 +253,91 @@ test('Should not change the input schemas', t => {
253
253
} )
254
254
} )
255
255
256
+ test ( 'Should throw if the schema body is undefined' , t => {
257
+ t . plan ( 2 )
258
+ const fastify = Fastify ( )
259
+
260
+ fastify . get ( '/:id' , {
261
+ handler : echoParams ,
262
+ schema : {
263
+ body : undefined
264
+ }
265
+ } )
266
+
267
+ fastify . ready ( err => {
268
+ t . equal ( err . code , 'FST_ERR_SCH_VALIDATION_BUILD' )
269
+ t . equal ( err . message , 'Failed building the validation schema for GET: /:id, due to error body schema is undefined' )
270
+ } )
271
+ } )
272
+
273
+ test ( 'Should throw if the schema headers is undefined' , t => {
274
+ t . plan ( 2 )
275
+ const fastify = Fastify ( )
276
+
277
+ fastify . get ( '/:id' , {
278
+ handler : echoParams ,
279
+ schema : {
280
+ headers : undefined
281
+ }
282
+ } )
283
+
284
+ fastify . ready ( err => {
285
+ t . equal ( err . code , 'FST_ERR_SCH_VALIDATION_BUILD' )
286
+ t . equal ( err . message , 'Failed building the validation schema for GET: /:id, due to error headers schema is undefined' )
287
+ } )
288
+ } )
289
+
290
+ test ( 'Should throw if the schema params is undefined' , t => {
291
+ t . plan ( 2 )
292
+ const fastify = Fastify ( )
293
+
294
+ fastify . get ( '/:id' , {
295
+ handler : echoParams ,
296
+ schema : {
297
+ params : undefined
298
+ }
299
+ } )
300
+
301
+ fastify . ready ( err => {
302
+ t . equal ( err . code , 'FST_ERR_SCH_VALIDATION_BUILD' )
303
+ t . equal ( err . message , 'Failed building the validation schema for GET: /:id, due to error params schema is undefined' )
304
+ } )
305
+ } )
306
+
307
+ test ( 'Should throw if the schema query is undefined' , t => {
308
+ t . plan ( 2 )
309
+ const fastify = Fastify ( )
310
+
311
+ fastify . get ( '/:id' , {
312
+ handler : echoParams ,
313
+ schema : {
314
+ querystring : undefined
315
+ }
316
+ } )
317
+
318
+ fastify . ready ( err => {
319
+ t . equal ( err . code , 'FST_ERR_SCH_VALIDATION_BUILD' )
320
+ t . equal ( err . message , 'Failed building the validation schema for GET: /:id, due to error querystring schema is undefined' )
321
+ } )
322
+ } )
323
+
324
+ test ( 'Should throw if the schema query is undefined' , t => {
325
+ t . plan ( 2 )
326
+ const fastify = Fastify ( )
327
+
328
+ fastify . get ( '/:id' , {
329
+ handler : echoParams ,
330
+ schema : {
331
+ querystring : undefined
332
+ }
333
+ } )
334
+
335
+ fastify . ready ( err => {
336
+ t . equal ( err . code , 'FST_ERR_SCH_VALIDATION_BUILD' )
337
+ t . equal ( err . message , 'Failed building the validation schema for GET: /:id, due to error querystring schema is undefined' )
338
+ } )
339
+ } )
340
+
256
341
test ( 'First level $ref' , t => {
257
342
t . plan ( 2 )
258
343
const fastify = Fastify ( )
0 commit comments