Negation swallows missing schema errors
tad-lispy opened this issue · 2 comments
tad-lispy commented
Consider this:
const schema = {
anyOf: [
{
"enum": 'some value'
},
{
$ref: 'invalid external schema reference'
}
]
};
expect('invalid value').not.to.be.jsonSchema(schema);
expect('some value').not.to.be.jsonSchema(schema);
Expected behaviour:
Test fails with missing schema error.
What happens instead:
The test will pass no matter what value is checked against schema.
JrSchild commented
I did some digging, turned out to be very simpel. When you define an enum it should always be an array. Therefore whatever you throw at it will never pass in this example. Try setting it to an array and it will work as expected.
http://spacetelescope.github.io/understanding-json-schema/reference/generic.html#enumerated-values
The enum keyword is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique.