Skip to content

Commit

Permalink
Improve test verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
mbasaglia committed Dec 11, 2024
1 parent 84ad1e4 commit 0196f58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions tests/validate_animations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,32 @@ const ajv = new Ajv({
});
const validate = ajv.compile(schema);

expect.extend({
toBeValid(data) {

if ( validate(data) )
{
return {
message: () => "data NOT be valid",
pass: true
};
}

return {
message: () => "Invalid data: " + JSON.stringify(validate.errors, null, 4),
pass: false
};
}
});

describe('run schema validation', () => {
describe('example animations', () => {
const exampleFiles = fs.readdirSync(EXAMPLES_DIR).map(file => EXAMPLES_DIR + file);

exampleFiles.forEach((file) => {
test(file, () => {
const animation = fs.readFileSync(file, 'utf8');
const valid = validate(JSON.parse(animation));

expect(valid).toBe(true);
expect(JSON.parse(animation)).toBeValid();
});
});
});
Expand All @@ -33,7 +49,7 @@ describe('run schema validation', () => {
test(file, () => {
const animation = fs.readFileSync(file, 'utf8');
const valid = validate(JSON.parse(animation));

expect(valid).toBe(true);
});
});
Expand All @@ -46,7 +62,7 @@ describe('run schema validation', () => {
test(file, () => {
const animation = fs.readFileSync(file, 'utf8');
const valid = validate(JSON.parse(animation));

expect(valid).toBe(false);
});
});
Expand Down
2 changes: 1 addition & 1 deletion tools/schema-merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def add_vals_to_unknown_object(

for ele in objects.concrete:
type = ele.properties.get('ty', None)
if type is not None and type.const:
if type is not None and type.const is not None:
types.append(type.const)

unknown_type_dict["properties"]["ty"]["not"]["enum"] = types
Expand Down

0 comments on commit 0196f58

Please sign in to comment.