Debian Codegraph @

test/tests/07 - $ref/06 - multiple refs.js

raw symbols SCIP
1 describe("$refs to $refs", function () {
2 it("addSchema(), $ref", function () {
3 var schema = {
4 id: "http://example.com/schema",
5 some: {
6 other: {type: "number"}
7 },
8 data: {'$ref': "#/some/other"}
9 };
10
11 tv4.addSchema(schema);
12 assert.isTrue(tv4.validate(42, {"$ref": "http://example.com/schema#/data"}), "42 valid");
13 //assert.isFalse(tv4.validate(42, {"$ref": "http://example.com/schema#/data"}), "\"42\" invalid");
14
15 assert.length(tv4.missing, 0, "should have no missing schemas");
16 });
17
18 it("Don't hang on circle", function () {
19 var schema = {
20 id: "http://example.com/schema",
21 ref1: {"$ref": "#/ref2"},
22 ref2: {"$ref": "#/ref1"}
23 };
24
25 tv4.addSchema(schema);
26 var result = tv4.validateResult(42, "http://example.com/schema#/ref1");
27
28 assert.isFalse(result.valid, "not valid");
29 assert.equal(result.error.code, tv4.errorCodes.CIRCULAR_REFERENCE, 'Error code correct');
30 });
31 });