2015-05-26 04:11:36 +03:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-24 12:23:40 +03:00
|
|
|
var jsonSchemaTest = require('json-schema-test')
|
2015-12-27 19:43:56 +03:00
|
|
|
, getAjvInstances = require('./ajv_instances')
|
2016-01-25 01:55:19 +03:00
|
|
|
, 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');
|
2015-06-12 20:16:54 +03:00
|
|
|
|
2015-05-30 21:11:06 +03:00
|
|
|
var remoteRefs = {
|
2016-07-28 02:50:30 +03:00
|
|
|
'http://localhost:1234/integer.json': require('./JSON-Schema-Test-Suite/remotes/integer.json'),
|
|
|
|
'http://localhost:1234/subSchemas.json': require('./JSON-Schema-Test-Suite/remotes/subSchemas.json'),
|
|
|
|
'http://localhost:1234/folder/folderInteger.json': require('./JSON-Schema-Test-Suite/remotes/folder/folderInteger.json'),
|
2015-05-30 21:11:06 +03:00
|
|
|
};
|
|
|
|
|
2017-03-12 20:27:10 +03:00
|
|
|
runTest(getAjvInstances(options, {meta: false}), 4, typeof window == 'object'
|
2017-03-12 20:10:16 +03:00
|
|
|
? suite(require('./JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json', {mode: 'list'}))
|
|
|
|
: './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json');
|
|
|
|
|
2017-03-12 20:27:10 +03:00
|
|
|
runTest(getAjvInstances(options), 6, typeof window == 'object'
|
2017-03-12 20:10:16 +03:00
|
|
|
? suite(require('./JSON-Schema-Test-Suite/tests/draft6/{**/,}*.json', {mode: 'list'}))
|
|
|
|
: './JSON-Schema-Test-Suite/tests/draft6/{**/,}*.json');
|
|
|
|
|
|
|
|
|
|
|
|
function runTest(instances, draft, tests) {
|
2017-03-12 20:27:10 +03:00
|
|
|
instances.forEach(function (ajv) {
|
|
|
|
ajv.addMetaSchema(require('../lib/refs/json-schema-draft-04.json'));
|
|
|
|
if (draft == 4) ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
|
|
|
|
for (var id in remoteRefs) ajv.addSchema(remoteRefs[id], id);
|
|
|
|
});
|
|
|
|
|
2017-03-12 20:10:16 +03:00
|
|
|
jsonSchemaTest(instances, {
|
|
|
|
description: 'JSON-Schema Test Suite draft-0' + draft + ': ' + instances.length + ' ajv instances with different options',
|
|
|
|
suites: {tests: tests},
|
|
|
|
only: [
|
|
|
|
// 'type', 'not', 'allOf', 'anyOf', 'oneOf', 'enum',
|
|
|
|
// 'maximum', 'minimum', 'multipleOf', 'maxLength', 'minLength', 'pattern',
|
|
|
|
// 'properties', 'patternProperties', 'additionalProperties',
|
|
|
|
// 'dependencies', 'required',
|
|
|
|
// 'maxProperties', 'minProperties', 'maxItems', 'minItems',
|
|
|
|
// 'items', 'additionalItems', 'uniqueItems',
|
|
|
|
// 'optional/format', 'optional/bignum',
|
|
|
|
// 'ref', 'refRemote', 'definitions',
|
|
|
|
],
|
|
|
|
skip: [ 'optional/zeroTerminatedFloats', 'optional/bignum' ],
|
|
|
|
assert: require('./chai').assert,
|
|
|
|
afterError: after.error,
|
|
|
|
afterEach: after.each,
|
|
|
|
cwd: __dirname,
|
|
|
|
hideFolder: 'draft' + draft + '/',
|
|
|
|
timeout: 120000
|
|
|
|
});
|
2015-05-26 04:11:36 +03:00
|
|
|
}
|