File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -20,3 +20,45 @@ test(`render a long as JSON`, (t) => {
20
20
t . equal ( output , '18446744073709551615' )
21
21
t . ok ( validate ( JSON . parse ( output ) ) , 'valid schema' )
22
22
} )
23
+
24
+ test ( `render an object with long as JSON` , ( t ) => {
25
+ t . plan ( 2 )
26
+
27
+ const schema = {
28
+ title : 'object with long' ,
29
+ type : 'object' ,
30
+ properties : {
31
+ id : {
32
+ type : 'integer'
33
+ }
34
+ }
35
+ }
36
+
37
+ const validate = validator ( schema )
38
+ const stringify = build ( schema )
39
+ const output = stringify ( {
40
+ id : Long . fromString ( '18446744073709551615' , true )
41
+ } )
42
+
43
+ t . equal ( output , '{"id":18446744073709551615}' )
44
+ t . ok ( validate ( JSON . parse ( output ) ) , 'valid schema' )
45
+ } )
46
+
47
+ test ( `render aan array with long as JSON` , ( t ) => {
48
+ t . plan ( 2 )
49
+
50
+ const schema = {
51
+ title : 'array with long' ,
52
+ type : 'array' ,
53
+ items : {
54
+ type : 'integer'
55
+ }
56
+ }
57
+
58
+ const validate = validator ( schema )
59
+ const stringify = build ( schema )
60
+ const output = stringify ( [ Long . fromString ( '18446744073709551615' , true ) ] )
61
+
62
+ t . equal ( output , '[18446744073709551615]' )
63
+ t . ok ( validate ( JSON . parse ( output ) ) , 'valid schema' )
64
+ } )
You can’t perform that action at this time.
0 commit comments