@@ -102,7 +102,7 @@ test('Should allow custom AJV instance for body', async t => {
102
102
103
103
const body = res . json ( )
104
104
105
- t . equal ( body . message , 'body must be array' )
105
+ t . equal ( body . message , 'body/msg must be array' )
106
106
t . equal (
107
107
res . statusCode ,
108
108
400 ,
@@ -147,7 +147,7 @@ test('Should allow custom AJV instance for params', async t => {
147
147
148
148
const body = res . json ( )
149
149
150
- t . equal ( body . message , 'params must be integer' )
150
+ t . equal ( body . message , 'params/msg must be integer' )
151
151
t . equal (
152
152
res . statusCode ,
153
153
400 ,
@@ -198,7 +198,7 @@ test('Should allow custom AJV instance for headers', async t => {
198
198
// TODO: set into documentation that it's possible the
199
199
// error formatter doesn't work as expected.
200
200
// Custom one should be provided
201
- t . equal ( body . message , 'headers must be integer' )
201
+ t . equal ( body . message , 'headers/x-type must be integer' )
202
202
t . equal (
203
203
res . statusCode ,
204
204
400 ,
@@ -261,7 +261,7 @@ test('Should work with referenced schemas (querystring)', async t => {
261
261
262
262
const body = res . json ( )
263
263
264
- t . equal ( body . message , 'querystring must be array' )
264
+ t . equal ( body . message , 'querystring/msg must be array' )
265
265
t . equal (
266
266
res . statusCode ,
267
267
400 ,
@@ -313,7 +313,7 @@ test('Should work with referenced schemas (params)', async t => {
313
313
314
314
const body = res . json ( )
315
315
316
- t . equal ( body . message , 'params must be integer' )
316
+ t . equal ( body . message , 'params/id must be integer' )
317
317
t . equal ( res . statusCode , 400 , 'Should not coearce the string into integer' )
318
318
} catch ( err ) {
319
319
t . error ( err )
@@ -364,7 +364,7 @@ test('Should work with referenced schemas (headers)', async t => {
364
364
365
365
const body = res . json ( )
366
366
367
- t . equal ( body . message , 'headers must be integer' )
367
+ t . equal ( body . message , 'headers/x-id must be integer' )
368
368
t . equal ( res . statusCode , 400 , 'Should not coearce the string into integer' )
369
369
} catch ( err ) {
370
370
t . error ( err )
@@ -417,7 +417,7 @@ test('Should work with referenced schemas (body)', async t => {
417
417
418
418
const body = res . json ( )
419
419
420
- t . equal ( body . message , 'body must be string' )
420
+ t . equal ( body . message , 'body/msg must be string' )
421
421
t . equal ( res . statusCode , 400 , 'Should not coearce the string into integer' )
422
422
} catch ( err ) {
423
423
t . error ( err )
@@ -485,7 +485,7 @@ test('Should work with parent and same instance schemas', async t => {
485
485
486
486
const body = res . json ( )
487
487
488
- t . equal ( body . message , 'body must be string' )
488
+ t . equal ( body . message , 'body/msg must be string' )
489
489
t . equal ( res . statusCode , 400 , 'Should not coearce the string into integer' )
490
490
} catch ( err ) {
491
491
t . error ( err )
@@ -543,7 +543,7 @@ test('Should work with parent schemas', async t => {
543
543
544
544
const body = res . json ( )
545
545
546
- t . equal ( body . message , 'body must be string' )
546
+ t . equal ( body . message , 'body/msg must be string' )
547
547
t . equal ( res . statusCode , 400 , 'Should not coearce the string into integer' )
548
548
} catch ( err ) {
549
549
t . error ( err )
@@ -623,9 +623,9 @@ test('Should work with parent nested schemas', async t => {
623
623
} )
624
624
] )
625
625
626
- t . equal ( res1 . json ( ) . message , 'querystring must be array' )
626
+ t . equal ( res1 . json ( ) . message , 'querystring/msg must be array' )
627
627
t . equal ( res1 . statusCode , 400 , 'Should not coearce the string into array' )
628
- t . equal ( res2 . json ( ) . message , 'headers must be integer' )
628
+ t . equal ( res2 . json ( ) . message , 'headers/x-another must be integer' )
629
629
t . equal ( res2 . statusCode , 400 , 'Should not coearce the string into integer' )
630
630
} catch ( err ) {
631
631
t . error ( err )
@@ -705,9 +705,9 @@ test('Should handle parsing to querystring (query)', async t => {
705
705
} )
706
706
] )
707
707
708
- t . equal ( res1 . json ( ) . message , 'querystring must be array' )
708
+ t . equal ( res1 . json ( ) . message , 'querystring/msg must be array' )
709
709
t . equal ( res1 . statusCode , 400 , 'Should not coearce the string into array' )
710
- t . equal ( res2 . json ( ) . message , 'headers must be integer' )
710
+ t . equal ( res2 . json ( ) . message , 'headers/x-another must be integer' )
711
711
t . equal ( res2 . statusCode , 400 , 'Should not coearce the string into integer' )
712
712
} catch ( err ) {
713
713
t . error ( err )
@@ -784,7 +784,7 @@ test('Should use default plugin validator as fallback', async t => {
784
784
}
785
785
} )
786
786
787
- t . equal ( res . json ( ) . message , 'querystring must be array' )
787
+ t . equal ( res . json ( ) . message , 'querystring/msg must be array' )
788
788
t . equal ( res . statusCode , 400 , 'Should not coearce the string into array' )
789
789
t . ok ( compileCalled , 'Should have called the default Ajv instance' )
790
790
} catch ( err ) {
@@ -807,6 +807,7 @@ test('Should always cache schema to default plugin validator', async t => {
807
807
}
808
808
809
809
headerAjv . compile = schema => {
810
+ console . log ( 'called' )
810
811
customCompileCalled = true
811
812
return headerDefaultCompile ( schema )
812
813
}
@@ -829,13 +830,13 @@ test('Should always cache schema to default plugin validator', async t => {
829
830
}
830
831
} )
831
832
832
- server . register ( ( instance , opts , done ) => {
833
+ server . register ( async ( instance , opts , done ) => {
833
834
instance . addSchema ( {
834
835
$id : 'another' ,
835
836
type : 'integer'
836
837
} )
837
838
838
- instance . register ( proxiedPlugin , { } )
839
+ await instance . register ( proxiedPlugin , { } )
839
840
840
841
instance . post (
841
842
'/' ,
@@ -862,8 +863,6 @@ test('Should always cache schema to default plugin validator', async t => {
862
863
reply . send ( { noop : 'noop' } )
863
864
}
864
865
)
865
-
866
- done ( )
867
866
} )
868
867
869
868
try {
@@ -872,10 +871,13 @@ test('Should always cache schema to default plugin validator', async t => {
872
871
url : '/' ,
873
872
query : {
874
873
msg : [ 'string' ]
874
+ } ,
875
+ headers : {
876
+ 'x-another' : 1
875
877
}
876
878
} )
877
879
878
- t . equal ( res . json ( ) . message , 'querystring must be array' )
880
+ t . equal ( res . json ( ) . message , 'querystring/msg must be array' )
879
881
t . equal ( res . statusCode , 400 , 'Should not coearce the string into array' )
880
882
t . ok ( compileCalled , 'Should have called the default Ajv instance' )
881
883
t . ok ( customCompileCalled , 'Should have called the custom Ajv instance' )
@@ -948,7 +950,7 @@ test('Should use default provided validator as fallback', async t => {
948
950
}
949
951
} )
950
952
951
- t . equal ( res . json ( ) . message , 'querystring must be array' )
953
+ t . equal ( res . json ( ) . message , 'querystring/msg must be array' )
952
954
t . equal ( res . statusCode , 400 , 'Should not coearce the string into array' )
953
955
t . ok ( compileCalled , 'Should have called the default Ajv instance' )
954
956
} catch ( err ) {
0 commit comments