| 1 |
describe("Ban unknown properties 02", function () { |
| 2 |
it("Do not track property definitions from \"not\"", function () { |
| 3 |
var schema = { |
| 4 |
"not": { |
| 5 |
properties: { |
| 6 |
propA: {"type": "string"}, |
| 7 |
} |
| 8 |
} |
| 9 |
}; |
| 10 |
var data = { |
| 11 |
propA: true, |
| 12 |
}; |
| 13 |
|
| 14 |
var result = tv4.validateMultiple(data, schema, false, true); |
| 15 |
assert.isFalse(result.valid, "Must not be valid"); |
| 16 |
}); |
| 17 |
|
| 18 |
it("Do not track property definitions from unselected \"oneOf\"", function () { |
| 19 |
var schema = { |
| 20 |
"oneOf": [ |
| 21 |
{ |
| 22 |
"type": "object", |
| 23 |
"properties": { |
| 24 |
"propA": {"type": "string"} |
| 25 |
} |
| 26 |
}, |
| 27 |
{ |
| 28 |
"type": "object", |
| 29 |
"properties": { |
| 30 |
"propB": {"type": "boolean"} |
| 31 |
} |
| 32 |
} |
| 33 |
] |
| 34 |
}; |
| 35 |
var data = { |
| 36 |
propA: true, |
| 37 |
propB: true |
| 38 |
}; |
| 39 |
|
| 40 |
var result = tv4.validateMultiple(data, schema, false, true); |
| 41 |
assert.isFalse(result.valid, "Must not be valid"); |
| 42 |
|
| 43 |
var result2 = tv4.validateMultiple(data, schema, false); |
| 44 |
assert.isTrue(result2.valid, "Must still be valid without flag"); |
| 45 |
}); |
| 46 |
|
| 47 |
|
| 48 |
it("Do not track property definitions from unselected \"anyOf\"", function () { |
| 49 |
var schema = { |
| 50 |
"anyOf": [ |
| 51 |
{ |
| 52 |
"type": "object", |
| 53 |
"properties": { |
| 54 |
"propA": {"type": "string"} |
| 55 |
} |
| 56 |
}, |
| 57 |
{ |
| 58 |
"type": "object", |
| 59 |
"properties": { |
| 60 |
"propB": {"type": "boolean"} |
| 61 |
} |
| 62 |
} |
| 63 |
] |
| 64 |
}; |
| 65 |
var data = { |
| 66 |
propA: true, |
| 67 |
propB: true |
| 68 |
}; |
| 69 |
|
| 70 |
var result = tv4.validateMultiple(data, schema, false, true); |
| 71 |
assert.isFalse(result.valid, "Must not be valid"); |
| 72 |
|
| 73 |
var result2 = tv4.validateMultiple(data, schema, false); |
| 74 |
assert.isTrue(result2.valid, "Must still be valid without flag"); |
| 75 |
}); |
| 76 |
}); |