Skip to content

Commit a3f9e2e

Browse files
Merge pull request #371 from karenetheridge/ether/if-then-else-boolean
some tests with if/then/else and boolean schemas
2 parents b8a083c + aeeaecc commit a3f9e2e

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,45 @@
184184
"valid": true
185185
}
186186
]
187+
},
188+
{
189+
"description": "if with boolean schema true",
190+
"schema": {
191+
"if": true,
192+
"then": { "const": "then" },
193+
"else": { "const": "else" }
194+
},
195+
"tests": [
196+
{
197+
"description": "boolean schema true in if always chooses the then path (valid)",
198+
"data": "then",
199+
"valid": true
200+
},
201+
{
202+
"description": "boolean schema true in if always chooses the then path (invalid)",
203+
"data": "else",
204+
"valid": false
205+
}
206+
]
207+
},
208+
{
209+
"description": "if with boolean schema false",
210+
"schema": {
211+
"if": false,
212+
"then": { "const": "then" },
213+
"else": { "const": "else" }
214+
},
215+
"tests": [
216+
{
217+
"description": "boolean schema false in if always chooses the else path (invalid)",
218+
"data": "then",
219+
"valid": false
220+
},
221+
{
222+
"description": "boolean schema false in if always chooses the else path (valid)",
223+
"data": "else",
224+
"valid": true
225+
}
226+
]
187227
}
188228
]

tests/draft7/if-then-else.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,45 @@
184184
"valid": true
185185
}
186186
]
187+
},
188+
{
189+
"description": "if with boolean schema true",
190+
"schema": {
191+
"if": true,
192+
"then": { "const": "then" },
193+
"else": { "const": "else" }
194+
},
195+
"tests": [
196+
{
197+
"description": "boolean schema true in if always chooses the then path (valid)",
198+
"data": "then",
199+
"valid": true
200+
},
201+
{
202+
"description": "boolean schema true in if always chooses the then path (invalid)",
203+
"data": "else",
204+
"valid": false
205+
}
206+
]
207+
},
208+
{
209+
"description": "if with boolean schema false",
210+
"schema": {
211+
"if": false,
212+
"then": { "const": "then" },
213+
"else": { "const": "else" }
214+
},
215+
"tests": [
216+
{
217+
"description": "boolean schema false in if always chooses the else path (invalid)",
218+
"data": "then",
219+
"valid": false
220+
},
221+
{
222+
"description": "boolean schema false in if always chooses the else path (valid)",
223+
"data": "else",
224+
"valid": true
225+
}
226+
]
187227
}
188228
]

0 commit comments

Comments
 (0)