| 1 |
import type AjvCore from "../dist/core" |
| 2 |
import _Ajv from "./ajv" |
| 3 |
import getAjvInstances from "./ajv_instances" |
| 4 |
import {withStandalone} from "./ajv_standalone" |
| 5 |
import * as jsonSchemaTest from "json-schema-test" |
| 6 |
import options from "./ajv_options" |
| 7 |
import {afterError, afterEach} from "./after_test" |
| 8 |
import ajvFormats from "ajv-formats" |
| 9 |
|
| 10 |
const instances = getAjvInstances(_Ajv, options, {strict: false, formats: {allowedUnknown: true}}) |
| 11 |
|
| 12 |
const remoteRefs = { |
| 13 |
"http://localhost:1234/integer.json": require("./JSON-Schema-Test-Suite/remotes/integer.json"), |
| 14 |
"http://localhost:1234/folder/folderInteger.json": require("./JSON-Schema-Test-Suite/remotes/baseUriChange/folderInteger.json"), |
| 15 |
"http://localhost:1234/name.json": require("./remotes/name.json"), |
| 16 |
} |
| 17 |
|
| 18 |
const remoteRefsWithIds = [ |
| 19 |
require("./remotes/bar.json"), |
| 20 |
require("./remotes/foo.json"), |
| 21 |
require("./remotes/buu.json"), |
| 22 |
require("./remotes/tree.json"), |
| 23 |
require("./remotes/node.json"), |
| 24 |
require("./remotes/second.json"), |
| 25 |
require("./remotes/first.json"), |
| 26 |
require("./remotes/scope_change.json"), |
| 27 |
] |
| 28 |
|
| 29 |
instances.forEach(addRemoteRefsAndFormats) |
| 30 |
|
| 31 |
jsonSchemaTest(withStandalone(instances), { |
| 32 |
description: `Schema tests of ${instances.length} ajv instances with different options`, |
| 33 |
suites: {"Schema tests": require("./_json/tests")}, |
| 34 |
only: [], |
| 35 |
assert: require("./chai").assert, |
| 36 |
afterError, |
| 37 |
afterEach, |
| 38 |
cwd: __dirname, |
| 39 |
timeout: 10000, |
| 40 |
}) |
| 41 |
|
| 42 |
function addRemoteRefsAndFormats(ajv: AjvCore) { |
| 43 |
ajv.opts.code.source = true |
| 44 |
for (const id in remoteRefs) ajv.addSchema(remoteRefs[id], id) |
| 45 |
ajv.addSchema(remoteRefsWithIds) |
| 46 |
ajvFormats(ajv) |
| 47 |
} |