@@ -104,11 +104,7 @@ test('object with field of type string and coercion disable ', (t) => {
104
104
}
105
105
}
106
106
const stringify = build ( schema )
107
-
108
- const value = stringify ( {
109
- str : 1
110
- } )
111
- t . equal ( value , '{"str":null}' )
107
+ t . throws ( ( ) => stringify ( { str : 1 } ) )
112
108
} )
113
109
114
110
test ( 'object with field of type string and coercion enable ' , ( t ) => {
@@ -403,7 +399,7 @@ test('oneOf object with field of type string with format or null', (t) => {
403
399
} )
404
400
405
401
test ( 'one array item match oneOf types' , ( t ) => {
406
- t . plan ( 1 )
402
+ t . plan ( 3 )
407
403
408
404
const schema = {
409
405
type : 'object' ,
@@ -429,15 +425,13 @@ test('one array item match oneOf types', (t) => {
429
425
430
426
const stringify = build ( schema )
431
427
432
- const responseWithMappedType = stringify ( {
433
- data : [ false , 'foo' ]
434
- } )
435
-
436
- t . equal ( '{"data":["foo"]}' , responseWithMappedType )
428
+ t . equal ( stringify ( { data : [ 'foo' ] } ) , '{"data":["foo"]}' )
429
+ t . equal ( stringify ( { data : [ 1 ] } ) , '{"data":[1]}' )
430
+ t . throws ( ( ) => stringify ( { data : [ false , 'foo' ] } ) )
437
431
} )
438
432
439
433
test ( 'some array items match oneOf types' , ( t ) => {
440
- t . plan ( 1 )
434
+ t . plan ( 2 )
441
435
442
436
const schema = {
443
437
type : 'object' ,
@@ -463,11 +457,8 @@ test('some array items match oneOf types', (t) => {
463
457
464
458
const stringify = build ( schema )
465
459
466
- const responseWithMappedTypes = stringify ( {
467
- data : [ false , 'foo' , true , 5 ]
468
- } )
469
-
470
- t . equal ( '{"data":["foo",5]}' , responseWithMappedTypes )
460
+ t . equal ( stringify ( { data : [ 'foo' , 5 ] } ) , '{"data":["foo",5]}' )
461
+ t . throws ( ( ) => stringify ( { data : [ false , 'foo' , true , 5 ] } ) )
471
462
} )
472
463
473
464
test ( 'all array items does not match oneOf types' , ( t ) => {
@@ -497,9 +488,5 @@ test('all array items does not match oneOf types', (t) => {
497
488
498
489
const stringify = build ( schema )
499
490
500
- const emptyResponse = stringify ( {
501
- data : [ null , false , true , undefined , [ ] , { } ]
502
- } )
503
-
504
- t . equal ( '{"data":[]}' , emptyResponse )
491
+ t . throws ( ( ) => stringify ( { data : [ null , false , true , undefined , [ ] , { } ] } ) )
505
492
} )
0 commit comments