-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: exception with useful message if $ref cannot be resolved
- Loading branch information
1 parent
5fc705f
commit 8fe8390
Showing
3 changed files
with
63 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
var Ajv = require('ajv'); | ||
var addKeywords = require('..'); | ||
var addMerge = require('../keywords/merge'); | ||
var addPatch = require('../keywords/patch'); | ||
var assert = require('assert'); | ||
|
||
describe('errors', function() { | ||
var ajv; | ||
|
||
describe('no v5 option', function() { | ||
beforeEach(function() { | ||
ajv = new Ajv; | ||
}); | ||
|
||
it('adding $merge and $patch should throw without v5 option', function() { | ||
assert.throws(function() { | ||
addKeywords(ajv); | ||
}); | ||
}); | ||
|
||
it('adding $merge only should throw without v5 option', function() { | ||
assert.throws(function() { | ||
addMerge(ajv); | ||
}); | ||
}); | ||
|
||
it('adding $patch only should throw without v5 option', function() { | ||
assert.throws(function() { | ||
addPatch(ajv); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('missing $ref', function() { | ||
beforeEach(function() { | ||
ajv = new Ajv({ v5: true }); | ||
addKeywords(ajv); | ||
}); | ||
|
||
it('should throw exception if cannot resolve $ref', function() { | ||
var schema = { | ||
"$merge": { | ||
"source": { "$ref": "obj.json#" }, | ||
"with": { | ||
"properties": { "q": { "type": "number" } } | ||
} | ||
} | ||
}; | ||
|
||
assert.throws(function() { | ||
ajv.compile(schema); | ||
}); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.