2016-10-04 23:16:18 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var jsonSchemaTest = require('json-schema-test')
|
|
|
|
, getAjvInstances = require('./ajv_instances')
|
|
|
|
, options = require('./ajv_options')
|
2016-12-03 22:26:30 +03:00
|
|
|
, suite = require('./browser_test_suite')
|
2016-10-04 23:16:18 +03:00
|
|
|
, after = require('./after_test');
|
|
|
|
|
2016-10-16 14:13:18 +03:00
|
|
|
var instances = getAjvInstances(options, {unknownFormats: ['allowedUnknown']});
|
2016-10-04 23:16:18 +03:00
|
|
|
|
|
|
|
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: [
|
|
|
|
// 'schemas/complex', 'schemas/basic', 'schemas/advanced',
|
|
|
|
],
|
|
|
|
assert: require('./chai').assert,
|
|
|
|
afterError: after.error,
|
|
|
|
afterEach: after.each,
|
|
|
|
cwd: __dirname,
|
|
|
|
timeout: 120000
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function addRemoteRefs(ajv) {
|
2016-12-22 00:11:59 +03:00
|
|
|
ajv.addMetaSchema(require('../lib/refs/json-schema-draft-04.json'));
|
2016-10-04 23:16:18 +03:00
|
|
|
for (var id in remoteRefs) ajv.addSchema(remoteRefs[id], id);
|
|
|
|
ajv.addSchema(remoteRefsWithIds);
|
|
|
|
}
|