| 1 |
describe("$ref 04", function () { |
| 2 |
|
| 3 |
it("addSchema(), $ref", function () { |
| 4 |
var url = "http://example.com/schema"; |
| 5 |
var schema = { |
| 6 |
"test": "value" |
| 7 |
}; |
| 8 |
tv4.addSchema(url, schema); |
| 9 |
|
| 10 |
var otherSchema = { |
| 11 |
"items": {"$ref": url} |
| 12 |
}; |
| 13 |
var valid = tv4.validate([0,1,2,3], otherSchema); |
| 14 |
|
| 15 |
assert.isTrue(valid, "should be valid"); |
| 16 |
assert.length(tv4.missing, 0, "should have no missing schemas"); |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
}); |
| 21 |
|
| 22 |
it("internal $ref", function () { |
| 23 |
var schema = { |
| 24 |
"type": "array", |
| 25 |
"items": {"$ref": "#"} |
| 26 |
}; |
| 27 |
|
| 28 |
assert.isTrue(tv4.validate([[],[[]]], schema), "List of lists should be valid"); |
| 29 |
assert.isTrue(!tv4.validate([0,1,2,3], schema), "List of ints should not"); |
| 30 |
assert.isTrue(!tv4.validate([[true], []], schema), "List of list with boolean should not"); |
| 31 |
|
| 32 |
assert.length(tv4.missing, 0, "should have no missing schemas"); |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
}); |
| 40 |
}); |