@@ -14,7 +14,7 @@ describe("compileSchema : getNodeChild", () => {
14
14
15
15
assert ( isSchemaNode ( node ) , "should have returned a valid schema node" ) ;
16
16
17
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 } ) ;
17
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 } ) ;
18
18
} ) ;
19
19
20
20
it ( "should return node of property even it type differs" , ( ) => {
@@ -27,7 +27,7 @@ describe("compileSchema : getNodeChild", () => {
27
27
28
28
assert ( isSchemaNode ( node ) , "should have returned a valid schema node" ) ;
29
29
30
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 } ) ;
30
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 } ) ;
31
31
} ) ;
32
32
33
33
it ( "should return undefined if property is not defined, but allowed" , ( ) => {
@@ -61,7 +61,7 @@ describe("compileSchema : getNodeChild", () => {
61
61
}
62
62
} ) . getNodeChild ( "title" , { body : "abc" } ) ;
63
63
64
- assert . deepEqual ( node . schema , { type : "string" , allOf : [ { minLength : 1 } ] } ) ;
64
+ assert . deepEqual ( node ? .schema , { type : "string" , allOf : [ { minLength : 1 } ] } ) ;
65
65
} ) ;
66
66
67
67
it ( "should reduce parent schema for returned property" , ( ) => {
@@ -79,7 +79,7 @@ describe("compileSchema : getNodeChild", () => {
79
79
]
80
80
} ) . getNodeChild ( "title" , { body : "abc" } ) ;
81
81
82
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 } ) ;
82
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 } ) ;
83
83
} ) ;
84
84
} ) ;
85
85
@@ -91,7 +91,7 @@ describe("compileSchema : getNodeChild", () => {
91
91
92
92
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
93
93
94
- assert . deepEqual ( node . schema , { anyOf : [ { multipleOf : 2 } , { multipleOf : 3 } ] } ) ;
94
+ assert . deepEqual ( node ? .schema , { anyOf : [ { multipleOf : 2 } , { multipleOf : 3 } ] } ) ;
95
95
} ) ;
96
96
} ) ;
97
97
@@ -107,7 +107,7 @@ describe("compileSchema : getNodeChild", () => {
107
107
108
108
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
109
109
110
- assert . deepEqual ( node . schema , { type : "string" , maxLength : 3 } ) ;
110
+ assert . deepEqual ( node ? .schema , { type : "string" , maxLength : 3 } ) ;
111
111
} ) ;
112
112
113
113
it ( "should reduce parent if-else schema when returning node" , ( ) => {
@@ -121,7 +121,7 @@ describe("compileSchema : getNodeChild", () => {
121
121
122
122
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
123
123
124
- assert . deepEqual ( node . schema , { type : "string" , minLength : 4 } ) ;
124
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 4 } ) ;
125
125
} ) ;
126
126
127
127
it ( "should reduce parent anyOf schema when returning property node" , ( ) => {
@@ -133,7 +133,7 @@ describe("compileSchema : getNodeChild", () => {
133
133
134
134
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
135
135
136
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 } ) ;
136
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 } ) ;
137
137
} ) ;
138
138
139
139
it ( "should reduce all matching parent anyOf schema when returning property node" , ( ) => {
@@ -145,7 +145,7 @@ describe("compileSchema : getNodeChild", () => {
145
145
146
146
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
147
147
148
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 , maxLength : 1 } ) ;
148
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 , maxLength : 1 } ) ;
149
149
} ) ;
150
150
151
151
it ( "should reduce all allOf schema when returning property node" , ( ) => {
@@ -157,7 +157,7 @@ describe("compileSchema : getNodeChild", () => {
157
157
158
158
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
159
159
160
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 , maxLength : 1 } ) ;
160
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 , maxLength : 1 } ) ;
161
161
} ) ;
162
162
163
163
it ( "should reduce matching oneOf schema when returning property node" , ( ) => {
@@ -169,7 +169,7 @@ describe("compileSchema : getNodeChild", () => {
169
169
170
170
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
171
171
172
- assert . deepEqual ( node . schema , { type : "string" , maxLength : 1 } ) ;
172
+ assert . deepEqual ( node ? .schema , { type : "string" , maxLength : 1 } ) ;
173
173
} ) ;
174
174
175
175
it ( "should return matching oneOf schema with `additionalProperties=false`" , ( ) => {
@@ -181,7 +181,7 @@ describe("compileSchema : getNodeChild", () => {
181
181
} ) . getNodeChild ( "title" , { title : "" } ) ;
182
182
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
183
183
184
- assert . deepEqual ( node . schema , { type : "string" } ) ;
184
+ assert . deepEqual ( node ? .schema , { type : "string" } ) ;
185
185
} ) ;
186
186
187
187
it ( "should return error when multiple oneOf-items match" , ( ) => {
@@ -216,7 +216,7 @@ describe("compileSchema : getNodeChild", () => {
216
216
217
217
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
218
218
219
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 } ) ;
219
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 } ) ;
220
220
} ) ;
221
221
222
222
it ( "should get merged property from patternProperties" , ( ) => {
@@ -228,7 +228,7 @@ describe("compileSchema : getNodeChild", () => {
228
228
229
229
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
230
230
231
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 , maxLength : 3 } ) ;
231
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 , maxLength : 3 } ) ;
232
232
} ) ;
233
233
234
234
it ( "should get property from merged allOf schema" , ( ) => {
@@ -239,7 +239,7 @@ describe("compileSchema : getNodeChild", () => {
239
239
240
240
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
241
241
242
- assert . deepEqual ( node . schema , { type : "string" , minLength : 1 } ) ;
242
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 1 } ) ;
243
243
} ) ;
244
244
245
245
it ( "should return combined allOf schema" , ( ) => {
@@ -260,7 +260,7 @@ describe("compileSchema : getNodeChild", () => {
260
260
261
261
const { node } = res . reduceNode ( { trigger : true } ) ;
262
262
263
- assert . deepEqual ( node . schema , {
263
+ assert . deepEqual ( node ? .schema , {
264
264
type : "object" ,
265
265
properties : {
266
266
trigger : { type : "boolean" } ,
@@ -281,7 +281,7 @@ describe("compileSchema : getNodeChild", () => {
281
281
282
282
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
283
283
284
- assert . deepEqual ( node . schema , { type : "number" , minimum : 1 } ) ;
284
+ assert . deepEqual ( node ? .schema , { type : "number" , minimum : 1 } ) ;
285
285
} ) ;
286
286
287
287
it ( "should get property from matching oneOf schema" , ( ) => {
@@ -295,7 +295,7 @@ describe("compileSchema : getNodeChild", () => {
295
295
296
296
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
297
297
298
- assert . deepEqual ( node . schema , { type : "string" , minLength : 2 } ) ;
298
+ assert . deepEqual ( node ? .schema , { type : "string" , minLength : 2 } ) ;
299
299
} ) ;
300
300
301
301
it ( "should return `undefined` for valid oneOf property missing the property" , ( ) => {
@@ -320,7 +320,7 @@ describe("compileSchema : getNodeChild", () => {
320
320
321
321
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
322
322
323
- assert . deepEqual ( node . schema , { type : "string" , maxLength : 2 } ) ;
323
+ assert . deepEqual ( node ? .schema , { type : "string" , maxLength : 2 } ) ;
324
324
} ) ;
325
325
326
326
it ( "should get property from else schema" , ( ) => {
@@ -333,7 +333,7 @@ describe("compileSchema : getNodeChild", () => {
333
333
334
334
assert ( isSchemaNode ( node ) , "should have returned a valid schema property node" ) ;
335
335
336
- assert . deepEqual ( node . schema , { type : "number" , minimum : 1 } ) ;
336
+ assert . deepEqual ( node ? .schema , { type : "number" , minimum : 1 } ) ;
337
337
} ) ;
338
338
} ) ;
339
339
@@ -372,7 +372,7 @@ describe("step", () => {
372
372
}
373
373
} ) . getNodeChild ( "title" ) ;
374
374
375
- assert . deepEqual ( node . schema , { type : "string" } ) ;
375
+ assert . deepEqual ( node ? .schema , { type : "string" } ) ;
376
376
} ) ;
377
377
378
378
it ( "should return error undefined for undefined schema" , ( ) => {
@@ -445,7 +445,7 @@ describe("step", () => {
445
445
{ type : "object" , properties : { title : { type : "number" } } }
446
446
]
447
447
} ) . getNodeChild ( "title" , { title : 4 } ) ;
448
- assert . deepEqual ( node . schema , { type : "number" } ) ;
448
+ assert . deepEqual ( node ? .schema , { type : "number" } ) ;
449
449
} ) ;
450
450
451
451
it ( "should return matching oneOf, for objects missing properties" , ( ) => {
@@ -455,7 +455,7 @@ describe("step", () => {
455
455
{ type : "object" , additionalProperties : { type : "number" } }
456
456
]
457
457
} ) . getNodeChild ( "title" , { title : 4 , test : 2 } ) ;
458
- assert . deepEqual ( node . schema , { type : "number" } ) ;
458
+ assert . deepEqual ( node ? .schema , { type : "number" } ) ;
459
459
} ) ;
460
460
461
461
it ( "should return matching anyOf" , ( ) => {
@@ -466,7 +466,7 @@ describe("step", () => {
466
466
]
467
467
} ) . getNodeChild ( "title" , { title : 4 , test : 2 } ) ;
468
468
469
- assert . deepEqual ( node . schema , { type : "number" } ) ;
469
+ assert . deepEqual ( node ? .schema , { type : "number" } ) ;
470
470
} ) ;
471
471
472
472
it ( "should return combined anyOf schema" , ( ) => {
@@ -478,7 +478,7 @@ describe("step", () => {
478
478
]
479
479
} ) . getNodeChild ( "title" , { title : 4 , test : 2 } ) ;
480
480
481
- assert . deepEqual ( node . schema , { type : "number" , minimum : 2 } ) ;
481
+ assert . deepEqual ( node ? .schema , { type : "number" , minimum : 2 } ) ;
482
482
} ) ;
483
483
484
484
it ( "should resolve references from anyOf schema" , ( ) => {
@@ -495,15 +495,15 @@ describe("step", () => {
495
495
]
496
496
} ) . getNodeChild ( "title" , { title : 4 , test : 2 } ) ;
497
497
498
- assert . deepEqual ( node . schema , { type : "number" , minimum : 2 } ) ;
498
+ assert . deepEqual ( node ? .schema , { type : "number" , minimum : 2 } ) ;
499
499
} ) ;
500
500
501
501
it ( "should return matching allOf schema" , ( ) => {
502
502
const { node } = compileSchema ( {
503
503
allOf : [ { type : "object" } , { additionalProperties : { type : "number" } } ]
504
504
} ) . getNodeChild ( "title" , { title : 4 , test : 2 } ) ;
505
505
506
- assert . deepEqual ( node . schema , { type : "number" } ) ;
506
+ assert . deepEqual ( node ? .schema , { type : "number" } ) ;
507
507
} ) ;
508
508
509
509
it ( "should resolve references in allOf schema" , ( ) => {
@@ -515,7 +515,7 @@ describe("step", () => {
515
515
allOf : [ { $ref : "#/definitions/object" } , { $ref : "#/definitions/additionalNumber" } ]
516
516
} ) . getNodeChild ( "title" , { title : 4 , test : 2 } ) ;
517
517
518
- assert . deepEqual ( node . schema , { type : "number" } ) ;
518
+ assert . deepEqual ( node ? .schema , { type : "number" } ) ;
519
519
} ) ;
520
520
521
521
it ( "should return matching patternProperty" , ( ) => {
@@ -527,7 +527,7 @@ describe("step", () => {
527
527
}
528
528
} ) . getNodeChild ( "second" ) ;
529
529
530
- assert . deepEqual ( node . schema , { type : "string" , id : "second" } ) ;
530
+ assert . deepEqual ( node ? .schema , { type : "string" , id : "second" } ) ;
531
531
} ) ;
532
532
533
533
it ( "should return additionalProperties schema for not matching patternProperty" , ( ) => {
@@ -540,7 +540,7 @@ describe("step", () => {
540
540
additionalProperties : { type : "object" }
541
541
} ) . getNodeChild ( "third" ) ;
542
542
543
- assert . deepEqual ( node . schema , { type : "object" } ) ;
543
+ assert . deepEqual ( node ? .schema , { type : "object" } ) ;
544
544
} ) ;
545
545
} ) ;
546
546
@@ -558,16 +558,16 @@ describe("step", () => {
558
558
type : "array" ,
559
559
items : { type : "string" }
560
560
} ) . getNodeChild ( 0 ) ;
561
- assert . deepEqual ( node . schema , { type : "string" } ) ;
561
+ assert . deepEqual ( node ? .schema , { type : "string" } ) ;
562
562
} ) ;
563
563
564
564
it ( "should return item at index" , ( ) => {
565
- const { node, error } = compileSchema ( {
565
+ const { node } = compileSchema ( {
566
566
type : "array" ,
567
567
prefixItems : [ { type : "string" } , { type : "number" } , { type : "boolean" } ]
568
568
} ) . getNodeChild ( 1 , [ "3" , 2 ] ) ;
569
569
570
- assert . deepEqual ( node . schema , { type : "number" } ) ;
570
+ assert . deepEqual ( node ? .schema , { type : "number" } ) ;
571
571
} ) ;
572
572
573
573
it ( "should return matching item in oneOf" , ( ) => {
@@ -583,7 +583,7 @@ describe("step", () => {
583
583
584
584
const { node } = res . reduceNode ( { title : 2 } ) ;
585
585
586
- assert . deepEqual ( node . schema , {
586
+ assert . deepEqual ( node ? .schema , {
587
587
type : "object" ,
588
588
properties : { title : { type : "number" } }
589
589
} ) ;
@@ -599,9 +599,10 @@ describe("step", () => {
599
599
}
600
600
} ) . getNodeChild ( 1 , [ { title : "two" } , { title : 4 } ] ) ;
601
601
602
+ assert ( res , "should have returned node" ) ;
602
603
const { node } = res . reduceNode ( { title : 4 } ) ;
603
604
604
- assert . deepEqual ( node . schema , { type : "object" , properties : { title : { type : "number" } } } ) ;
605
+ assert . deepEqual ( node ? .schema , { type : "object" , properties : { title : { type : "number" } } } ) ;
605
606
} ) ;
606
607
607
608
it ( "should return combined anyOf schema" , ( ) => {
@@ -615,9 +616,10 @@ describe("step", () => {
615
616
}
616
617
} ) . getNodeChild ( 1 , [ { title : "two" } , { title : 4 } ] ) ;
617
618
619
+ assert ( res , "should have returned node" ) ;
618
620
const { node } = res . reduceNode ( { title : 4 } ) ;
619
621
620
- assert . deepEqual ( node . schema , { type : "object" , properties : { title : { type : "number" , minimum : 2 } } } ) ;
622
+ assert . deepEqual ( node ? .schema , { type : "object" , properties : { title : { type : "number" , minimum : 2 } } } ) ;
621
623
} ) ;
622
624
623
625
it ( "should return combined allOf schema" , ( ) => {
@@ -630,9 +632,10 @@ describe("step", () => {
630
632
}
631
633
} ) . getNodeChild ( 1 , [ { title : "two" } , { title : 4 } ] ) ;
632
634
635
+ assert ( res , "should have returned node" ) ;
633
636
const { node } = res . reduceNode ( { title : "two" } ) ;
634
637
635
- assert . deepEqual ( node . schema , {
638
+ assert . deepEqual ( node ? .schema , {
636
639
type : "object" ,
637
640
properties : { title : { type : "number" , minimum : 3 } }
638
641
} ) ;
0 commit comments