forked from ajv-validator/ajv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema-tests.spec.js
51 lines (42 loc) · 1.51 KB
/
schema-tests.spec.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
45
46
47
48
49
50
51
'use strict';
var jsonSchemaTest = require('json-schema-test')
, getAjvInstances = require('./ajv_instances')
, options = require('./ajv_options')
, suite = require('./browser_test_suite')
, after = require('./after_test');
var instances = getAjvInstances(options, {unknownFormats: ['allowedUnknown']});
var remoteRefs = {
'http://localhost:1234/integer.json': require('./JSON-Schema-Test-Suite/remotes/integer.json'),
'http://localhost:1234/folder/folderInteger.json': require('./JSON-Schema-Test-Suite/remotes/folder/folderInteger.json'),
'http://localhost:1234/name.json': require('./remotes/name.json')
};
var remoteRefsWithIds = [
require('./remotes/bar.json'),
require('./remotes/foo.json'),
require('./remotes/buu.json'),
require('./remotes/tree.json'),
require('./remotes/node.json'),
require('./remotes/second.json'),
require('./remotes/first.json'),
require('./remotes/scope_change.json'),
];
instances.forEach(addRemoteRefs);
jsonSchemaTest(instances, {
description: 'Schema tests of ' + instances.length + ' ajv instances with different options',
suites: {
'Advanced schema tests':
typeof window == 'object'
? suite(require('./tests/{**/,}*.json', {mode: 'list'}))
: './tests/{**/,}*.json'
},
only: [],
assert: require('./chai').assert,
afterError: after.error,
afterEach: after.each,
cwd: __dirname,
timeout: 120000
});
function addRemoteRefs(ajv) {
for (var id in remoteRefs) ajv.addSchema(remoteRefs[id], id);
ajv.addSchema(remoteRefsWithIds);
}