File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,31 @@ test('possibly nullable primitive alternative', (t) => {
28
28
}
29
29
} )
30
30
31
+ test ( 'possibly nullable primitive alternative with null value' , ( t ) => {
32
+ t . plan ( 1 )
33
+
34
+ const schema = {
35
+ title : 'simple object with multi-type nullable primitive' ,
36
+ type : 'object' ,
37
+ properties : {
38
+ data : {
39
+ type : [ 'integer' ]
40
+ }
41
+ }
42
+ }
43
+
44
+ const stringify = build ( schema )
45
+
46
+ try {
47
+ const value = stringify ( {
48
+ data : null
49
+ } )
50
+ t . is ( value , '{"data":null}' )
51
+ } catch ( e ) {
52
+ t . fail ( )
53
+ }
54
+ } )
55
+
31
56
test ( 'nullable primitive' , ( t ) => {
32
57
t . plan ( 1 )
33
58
@@ -53,6 +78,31 @@ test('nullable primitive', (t) => {
53
78
}
54
79
} )
55
80
81
+ test ( 'nullable primitive with null value' , ( t ) => {
82
+ t . plan ( 1 )
83
+
84
+ const schema = {
85
+ title : 'simple object with nullable primitive' ,
86
+ type : 'object' ,
87
+ properties : {
88
+ data : {
89
+ type : [ 'integer' , 'null' ]
90
+ }
91
+ }
92
+ }
93
+
94
+ const stringify = build ( schema )
95
+
96
+ try {
97
+ const value = stringify ( {
98
+ data : null
99
+ } )
100
+ t . is ( value , '{"data":null}' )
101
+ } catch ( e ) {
102
+ t . fail ( )
103
+ }
104
+ } )
105
+
56
106
test ( 'possibly null object with multi-type property' , ( t ) => {
57
107
t . plan ( 3 )
58
108
You can’t perform that action at this time.
0 commit comments