Skip to content

Commit 9a64bbb

Browse files
committed
Added if/then/else sequencing tests; resolves json-schema-org#436
1 parent d082963 commit 9a64bbb

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

tests/draft2019-09/if-then-else.json

+30
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,35 @@
224224
"valid": true
225225
}
226226
]
227+
},
228+
{
229+
"description": "if appears at the end when serialized (keyword processing sequence)",
230+
"schema": {
231+
"then": { "const": "yes" },
232+
"else": { "const": "other" },
233+
"if": { "maxLength": 4 }
234+
},
235+
"tests": [
236+
{
237+
"description": "yes redirects to then and passes",
238+
"data": "yes",
239+
"valid": true
240+
},
241+
{
242+
"description": "other redirects to else and passes",
243+
"data": "other",
244+
"valid": true
245+
},
246+
{
247+
"description": "no redirects to then and fails",
248+
"data": "no",
249+
"valid": false
250+
},
251+
{
252+
"description": "invalid redirects to else and fails",
253+
"data": "invalid",
254+
"valid": false
255+
}
256+
]
227257
}
228258
]

tests/draft7/if-then-else.json

+30
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,35 @@
224224
"valid": true
225225
}
226226
]
227+
},
228+
{
229+
"description": "if appears at the end when serialized (keyword processing sequence)",
230+
"schema": {
231+
"then": { "const": "yes" },
232+
"else": { "const": "other" },
233+
"if": { "maxLength": 4 }
234+
},
235+
"tests": [
236+
{
237+
"description": "yes redirects to then and passes",
238+
"data": "yes",
239+
"valid": true
240+
},
241+
{
242+
"description": "other redirects to else and passes",
243+
"data": "other",
244+
"valid": true
245+
},
246+
{
247+
"description": "no redirects to then and fails",
248+
"data": "no",
249+
"valid": false
250+
},
251+
{
252+
"description": "invalid redirects to else and fails",
253+
"data": "invalid",
254+
"valid": false
255+
}
256+
]
227257
}
228258
]

0 commit comments

Comments
 (0)