Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schemas for all JSON extracts #731

Closed
wants to merge 13 commits into from
46 changes: 38 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions test/schemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Test individual elements extracts.
*
* The tests run against the curated view of the extracts.
*/

const fs = require('fs');
const path = require('path');
const assert = require('assert').strict;
const { getSchemaValidationFunction } = require('reffy');

const curatedFolder = path.join(__dirname, '..', 'curated');
const files = fs.readdirSync(curatedFolder);
for (const file of files) {
const validate = getSchemaValidationFunction(file);
if (file.endsWith('.json')) {
describe(`The ${file} file`, function () {
it('contains valid data', function () {
const data = require(path.join(curatedFolder, file));
const errors = validate(data);
assert.strictEqual(errors, null, JSON.stringify(errors, null, 2));
});
});
}
else {
describe(`The ${file} folder`, function () {
const extractType = file;
const folder = path.join(curatedFolder, extractType);
const files = fs.readdirSync(folder);
for (const file of files) {
if (file.endsWith('.json')) {
it(`contains valid ${extractType} data in ${file}`, () => {
const data = require(path.join(folder, file));
const errors = validate(data);
assert.strictEqual(errors, null, JSON.stringify(errors, null, 2));
});
}
}
});
}
}