test: fix browser tests, replace id with $id

master
Evgeny Poberezkin 2017-12-02 19:35:57 +00:00
parent 85839c278d
commit dad7132adf
6 changed files with 12 additions and 8 deletions

View File

@ -27,8 +27,8 @@ describe('Ajv', function () {
});
it('should cache compiled functions for the same schema', function() {
var v1 = ajv.compile({ id: '//e.com/int.json', type: 'integer', minimum: 1 });
var v2 = ajv.compile({ id: '//e.com/int.json', minimum: 1, type: 'integer' });
var v1 = ajv.compile({ $id: '//e.com/int.json', type: 'integer', minimum: 1 });
var v2 = ajv.compile({ $id: '//e.com/int.json', minimum: 1, type: 'integer' });
v1 .should.equal(v2);
});

View File

@ -375,7 +375,7 @@ describe('compileAsync method', function() {
it('if loadSchema returned error', function() {
var schema = {
"id": "http://example.com/parent.json",
"$id": "http://example.com/parent.json",
"properties": {
"a": { "$ref": "object.json" }
}

View File

@ -2,6 +2,8 @@
module.exports = function (suite) {
suite.forEach(function (file) {
if (file.name.indexOf('optional/format') == 0)
file.name = file.name.replace('optional/', '');
file.test = file.module;
});
return suite;

View File

@ -410,7 +410,7 @@ describe('Validation errors', function () {
it('"items" errors should include item index without quotes in dataPath (#48)', function() {
var schema1 = {
id: 'schema1',
$id: 'schema1',
type: 'array',
items: {
type: 'integer',
@ -445,7 +445,7 @@ describe('Validation errors', function () {
shouldBeError(fullValidate.errors[1], 'minimum', '#/items/minimum', '/3', 'should be >= 10');
var schema2 = {
id: 'schema2',
$id: 'schema2',
type: 'array',
items: [{ minimum: 10 }, { minimum: 9 }, { minimum: 12 }]
};

View File

@ -1153,7 +1153,9 @@ describe('Ajv Options', function () {
describe('= "id"', function() {
it('should use id and ignore $id', function() {
var ajv = new Ajv({schemaId: 'id'});
var ajv = new Ajv({schemaId: 'id', meta: false});
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
ajv.addSchema({ id: 'mySchema1', type: 'string' });
var validate = ajv.getSchema('mySchema1');

View File

@ -56,9 +56,9 @@
{
"description": "if keyword with id in sibling subschema",
"schema": {
"id": "http://example.com/base_if",
"$id": "http://example.com/base_if",
"if": {
"id": "http://example.com/if",
"$id": "http://example.com/if",
"minimum": 10
},
"then": { "$ref": "#/definitions/def" },