File tree Expand file tree Collapse file tree 1 file changed +51
-2
lines changed Expand file tree Collapse file tree 1 file changed +51
-2
lines changed Original file line number Diff line number Diff line change 3
3
const test = require ( 'tap' ) . test
4
4
const build = require ( '..' )
5
5
6
- test ( 'object with multiple types field ' , ( t ) => {
6
+ test ( 'object with allOf and multiple schema on the allOf ' , ( t ) => {
7
7
t . plan ( 2 )
8
8
9
9
const schema = {
10
- title : 'object with multiple types field ' ,
10
+ title : 'object with allOf and multiple schema on the allOf ' ,
11
11
type : 'object' ,
12
12
allOf : [
13
13
{
@@ -60,3 +60,52 @@ test('object with multiple types field', (t) => {
60
60
t . fail ( )
61
61
}
62
62
} )
63
+
64
+ test ( 'object with allOf and one schema on the allOf' , ( t ) => {
65
+ t . plan ( 1 )
66
+
67
+ const schema = {
68
+ title : 'object with allOf and one schema on the allOf' ,
69
+ type : 'object' ,
70
+ allOf : [
71
+ {
72
+ required : [
73
+ 'id'
74
+ ] ,
75
+ type : 'object' ,
76
+ properties : {
77
+ id : {
78
+ type : 'integer'
79
+ }
80
+ }
81
+ }
82
+ ]
83
+ }
84
+ const stringify = build ( schema )
85
+
86
+ try {
87
+ const value = stringify ( {
88
+ id : 1
89
+ } )
90
+ t . is ( value , '{"id":1}' )
91
+ } catch ( e ) {
92
+ t . fail ( )
93
+ }
94
+ } )
95
+
96
+ test ( 'object with allOf and no schema on the allOf' , ( t ) => {
97
+ t . plan ( 1 )
98
+
99
+ const schema = {
100
+ title : 'object with allOf and no schema on the allOf' ,
101
+ type : 'object' ,
102
+ allOf : [ ]
103
+ }
104
+
105
+ try {
106
+ build ( schema )
107
+ t . fail ( )
108
+ } catch ( e ) {
109
+ t . is ( e . message , 'schema is invalid: data.allOf should NOT have less than 1 items' )
110
+ }
111
+ } )
You can’t perform that action at this time.
0 commit comments