-
-
Notifications
You must be signed in to change notification settings - Fork 209
/
index.js
44 lines (39 loc) · 1.32 KB
/
index.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
37
38
39
40
41
42
43
44
'use strict';
const Ajv = require('ajv');
const jsonSchemaTest = require('json-schema-test');
const refs = {
'http://localhost:1234/integer.json': require('./remotes/integer.json'),
'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'),
'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json'),
'http://localhost:1234/name.json': require('./remotes/name.json'),
'http://localhost:1234/name-defs.json': require('./remotes/name-defs.json')
};
const SKIP = {
4: ['optional/zeroTerminatedFloats'],
7: [
'format/idn-email',
'format/idn-hostname',
'format/iri',
'format/iri-reference',
'optional/content'
]
};
[4, 6, 7].forEach((draft) => {
let ajv;
if (draft == 7) {
ajv = new Ajv({format: 'full'});
} else {
const schemaId = draft == 4 ? 'id' : '$id';
ajv = new Ajv({format: 'full', meta: false, schemaId});
ajv.addMetaSchema(require(`ajv/lib/refs/json-schema-draft-0${draft}.json`));
ajv._opts.defaultMeta = `http://json-schema.org/draft-0${draft}/schema#`;
}
for (const uri in refs) ajv.addSchema(refs[uri], uri);
jsonSchemaTest(ajv, {
description: `Test suite draft-0${draft}`,
suites: {tests: `./tests/draft${draft}/{**/,}*.json`},
skip: SKIP[draft],
cwd: __dirname,
hideFolder: 'tests/'
});
});