Validate generated json schemas in the tests
parent
44e36854f3
commit
c6fdf55ff2
|
@ -0,0 +1,9 @@
|
||||||
|
declare module 'ajv' {
|
||||||
|
declare export default class Ajv {
|
||||||
|
errors: {message: string}[];
|
||||||
|
|
||||||
|
constructor(): void;
|
||||||
|
|
||||||
|
validateSchema(schema: mixed): boolean;
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,7 @@
|
||||||
"@babel/preset-env": "^7.0.0-beta.32",
|
"@babel/preset-env": "^7.0.0-beta.32",
|
||||||
"@babel/preset-flow": "^7.0.0-beta.32",
|
"@babel/preset-flow": "^7.0.0-beta.32",
|
||||||
"@babel/register": "^7.0.0-beta.32",
|
"@babel/register": "^7.0.0-beta.32",
|
||||||
|
"ajv": "^5.5.1",
|
||||||
"flow-bin": "^0.60.1",
|
"flow-bin": "^0.60.1",
|
||||||
"jasmine": "^2.8.0",
|
"jasmine": "^2.8.0",
|
||||||
"mocha": "^4.0.1",
|
"mocha": "^4.0.1",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as yaml from 'yaml-js';
|
import * as yaml from 'yaml-js';
|
||||||
import wu from 'wu';
|
import wu from 'wu';
|
||||||
|
import Ajv from 'ajv';
|
||||||
|
|
||||||
import collect from '../src';
|
import collect from '../src';
|
||||||
|
|
||||||
|
@ -22,6 +23,14 @@ function run(title) {
|
||||||
it('should provide expected types', () => {
|
it('should provide expected types', () => {
|
||||||
assert.deepEqual(actual.types, expected);
|
assert.deepEqual(actual.types, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should generate valid JSON schema', () => {
|
||||||
|
const ajv = new Ajv;
|
||||||
|
|
||||||
|
ajv.validateSchema(actual.schema);
|
||||||
|
|
||||||
|
assert.equal(ajv.errors, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectCycles(obj: mixed, cycles: Set<mixed> = new Set, objs: Set<mixed> = new Set) {
|
function detectCycles(obj: mixed, cycles: Set<mixed> = new Set, objs: Set<mixed> = new Set) {
|
||||||
|
|
Loading…
Reference in New Issue