Skip to content

Commit fd0aa9f

Browse files
authored
Merge pull request #500 from anexia-it/master
Extend if/then/else tests on unevaluated properties
2 parents 017d4e5 + d010780 commit fd0aa9f

File tree

3 files changed

+318
-0
lines changed

3 files changed

+318
-0
lines changed

tests/draft-future/unevaluatedProperties.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,112 @@
491491
}
492492
]
493493
},
494+
{
495+
"description": "unevaluatedProperties with if/then/else, then not defined",
496+
"schema": {
497+
"type": "object",
498+
"if": {
499+
"properties": {
500+
"foo": { "const": "then" }
501+
},
502+
"required": ["foo"]
503+
},
504+
"else": {
505+
"properties": {
506+
"baz": { "type": "string" }
507+
},
508+
"required": ["baz"]
509+
},
510+
"unevaluatedProperties": false
511+
},
512+
"tests": [
513+
{
514+
"description": "when if is true and has no unevaluated properties",
515+
"data": {
516+
"foo": "then",
517+
"bar": "bar"
518+
},
519+
"valid": false
520+
},
521+
{
522+
"description": "when if is true and has unevaluated properties",
523+
"data": {
524+
"foo": "then",
525+
"bar": "bar",
526+
"baz": "baz"
527+
},
528+
"valid": false
529+
},
530+
{
531+
"description": "when if is false and has no unevaluated properties",
532+
"data": {
533+
"baz": "baz"
534+
},
535+
"valid": true
536+
},
537+
{
538+
"description": "when if is false and has unevaluated properties",
539+
"data": {
540+
"foo": "else",
541+
"baz": "baz"
542+
},
543+
"valid": false
544+
}
545+
]
546+
},
547+
{
548+
"description": "unevaluatedProperties with if/then/else, else not defined",
549+
"schema": {
550+
"type": "object",
551+
"if": {
552+
"properties": {
553+
"foo": { "const": "then" }
554+
},
555+
"required": ["foo"]
556+
},
557+
"then": {
558+
"properties": {
559+
"bar": { "type": "string" }
560+
},
561+
"required": ["bar"]
562+
},
563+
"unevaluatedProperties": false
564+
},
565+
"tests": [
566+
{
567+
"description": "when if is true and has no unevaluated properties",
568+
"data": {
569+
"foo": "then",
570+
"bar": "bar"
571+
},
572+
"valid": true
573+
},
574+
{
575+
"description": "when if is true and has unevaluated properties",
576+
"data": {
577+
"foo": "then",
578+
"bar": "bar",
579+
"baz": "baz"
580+
},
581+
"valid": false
582+
},
583+
{
584+
"description": "when if is false and has no unevaluated properties",
585+
"data": {
586+
"baz": "baz"
587+
},
588+
"valid": false
589+
},
590+
{
591+
"description": "when if is false and has unevaluated properties",
592+
"data": {
593+
"foo": "else",
594+
"baz": "baz"
595+
},
596+
"valid": false
597+
}
598+
]
599+
},
494600
{
495601
"description": "unevaluatedProperties with dependentSchemas",
496602
"schema": {

tests/draft2019-09/unevaluatedProperties.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,112 @@
491491
}
492492
]
493493
},
494+
{
495+
"description": "unevaluatedProperties with if/then/else, then not defined",
496+
"schema": {
497+
"type": "object",
498+
"if": {
499+
"properties": {
500+
"foo": { "const": "then" }
501+
},
502+
"required": ["foo"]
503+
},
504+
"else": {
505+
"properties": {
506+
"baz": { "type": "string" }
507+
},
508+
"required": ["baz"]
509+
},
510+
"unevaluatedProperties": false
511+
},
512+
"tests": [
513+
{
514+
"description": "when if is true and has no unevaluated properties",
515+
"data": {
516+
"foo": "then",
517+
"bar": "bar"
518+
},
519+
"valid": false
520+
},
521+
{
522+
"description": "when if is true and has unevaluated properties",
523+
"data": {
524+
"foo": "then",
525+
"bar": "bar",
526+
"baz": "baz"
527+
},
528+
"valid": false
529+
},
530+
{
531+
"description": "when if is false and has no unevaluated properties",
532+
"data": {
533+
"baz": "baz"
534+
},
535+
"valid": true
536+
},
537+
{
538+
"description": "when if is false and has unevaluated properties",
539+
"data": {
540+
"foo": "else",
541+
"baz": "baz"
542+
},
543+
"valid": false
544+
}
545+
]
546+
},
547+
{
548+
"description": "unevaluatedProperties with if/then/else, else not defined",
549+
"schema": {
550+
"type": "object",
551+
"if": {
552+
"properties": {
553+
"foo": { "const": "then" }
554+
},
555+
"required": ["foo"]
556+
},
557+
"then": {
558+
"properties": {
559+
"bar": { "type": "string" }
560+
},
561+
"required": ["bar"]
562+
},
563+
"unevaluatedProperties": false
564+
},
565+
"tests": [
566+
{
567+
"description": "when if is true and has no unevaluated properties",
568+
"data": {
569+
"foo": "then",
570+
"bar": "bar"
571+
},
572+
"valid": true
573+
},
574+
{
575+
"description": "when if is true and has unevaluated properties",
576+
"data": {
577+
"foo": "then",
578+
"bar": "bar",
579+
"baz": "baz"
580+
},
581+
"valid": false
582+
},
583+
{
584+
"description": "when if is false and has no unevaluated properties",
585+
"data": {
586+
"baz": "baz"
587+
},
588+
"valid": false
589+
},
590+
{
591+
"description": "when if is false and has unevaluated properties",
592+
"data": {
593+
"foo": "else",
594+
"baz": "baz"
595+
},
596+
"valid": false
597+
}
598+
]
599+
},
494600
{
495601
"description": "unevaluatedProperties with dependentSchemas",
496602
"schema": {

tests/draft2020-12/unevaluatedProperties.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,112 @@
491491
}
492492
]
493493
},
494+
{
495+
"description": "unevaluatedProperties with if/then/else, then not defined",
496+
"schema": {
497+
"type": "object",
498+
"if": {
499+
"properties": {
500+
"foo": { "const": "then" }
501+
},
502+
"required": ["foo"]
503+
},
504+
"else": {
505+
"properties": {
506+
"baz": { "type": "string" }
507+
},
508+
"required": ["baz"]
509+
},
510+
"unevaluatedProperties": false
511+
},
512+
"tests": [
513+
{
514+
"description": "when if is true and has no unevaluated properties",
515+
"data": {
516+
"foo": "then",
517+
"bar": "bar"
518+
},
519+
"valid": false
520+
},
521+
{
522+
"description": "when if is true and has unevaluated properties",
523+
"data": {
524+
"foo": "then",
525+
"bar": "bar",
526+
"baz": "baz"
527+
},
528+
"valid": false
529+
},
530+
{
531+
"description": "when if is false and has no unevaluated properties",
532+
"data": {
533+
"baz": "baz"
534+
},
535+
"valid": true
536+
},
537+
{
538+
"description": "when if is false and has unevaluated properties",
539+
"data": {
540+
"foo": "else",
541+
"baz": "baz"
542+
},
543+
"valid": false
544+
}
545+
]
546+
},
547+
{
548+
"description": "unevaluatedProperties with if/then/else, else not defined",
549+
"schema": {
550+
"type": "object",
551+
"if": {
552+
"properties": {
553+
"foo": { "const": "then" }
554+
},
555+
"required": ["foo"]
556+
},
557+
"then": {
558+
"properties": {
559+
"bar": { "type": "string" }
560+
},
561+
"required": ["bar"]
562+
},
563+
"unevaluatedProperties": false
564+
},
565+
"tests": [
566+
{
567+
"description": "when if is true and has no unevaluated properties",
568+
"data": {
569+
"foo": "then",
570+
"bar": "bar"
571+
},
572+
"valid": true
573+
},
574+
{
575+
"description": "when if is true and has unevaluated properties",
576+
"data": {
577+
"foo": "then",
578+
"bar": "bar",
579+
"baz": "baz"
580+
},
581+
"valid": false
582+
},
583+
{
584+
"description": "when if is false and has no unevaluated properties",
585+
"data": {
586+
"baz": "baz"
587+
},
588+
"valid": false
589+
},
590+
{
591+
"description": "when if is false and has unevaluated properties",
592+
"data": {
593+
"foo": "else",
594+
"baz": "baz"
595+
},
596+
"valid": false
597+
}
598+
]
599+
},
494600
{
495601
"description": "unevaluatedProperties with dependentSchemas",
496602
"schema": {

0 commit comments

Comments
 (0)