-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_definitions.js
36 lines (29 loc) · 1.03 KB
/
test_definitions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require('source-map-support').install();
const path = require('path');
const fs = require('fs-extra');
const expect = require('chai').expect;
const JSONValidation = require('json-validation').JSONValidation;
const definitionSchema = fs.readFileSync(
path.resolve(__dirname, '..', 'src', 'definition.schema.json'),
'utf-8'
);
describe('validate test definitions', () => {
let dirname = path.resolve(__dirname, 'definitions');
fs.readdirSync(dirname).forEach((fname) => {
if (path.extname === '.json') {
it(`should validate ${fname}`, () => {
return fs
.readFile(path.join(dirname, fname), 'utf-8')
.then((content) => {
const definition = JSON.parse(content);
const jv = new JSONValidation();
let result = jv.validate(definition, definitionSchema);
const errorMsg =
'Definition has the following errors: ' +
result.errors.join(', ');
expect(result.ok, errorMsg).to.be.true;
});
});
}
});
});