Debian Codegraph @

spec/issues/815_id_updates_ref_base.spec.ts

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 import type {ValidateFunction} from "../.."
2 import _Ajv from "../ajv"
3 import chai from "../chai"
4 chai.should()
5
6 describe("issue #815, id and $id fields should reset base", () => {
7 let validate: ValidateFunction
8
9 const schema = {
10 type: "object",
11 properties: {
12 newRoot: {
13 $id: "http://example.com/newRoot",
14 type: "object",
15 properties: {
16 recurse: {
17 $ref: "#",
18 },
19 name: {
20 type: "string",
21 },
22 },
23 required: ["name"],
24 additionalProperties: false,
25 },
26 },
27 required: ["newRoot"],
28 additionalProperties: false,
29 }
30
31 before(() => {
32 validate = new _Ajv().compile(schema)
33 })
34
35 it("should set # to reference the closest ancestor with $id", () => {
36 validate({
37 newRoot: {
38 name: "test",
39 },
40 }).should.equal(true)
41
42 validate({
43 newRoot: {
44 name: "test",
45 recurse: {
46 name: "test2",
47 },
48 },
49 }).should.equal(true)
50 })
51
52 it("should NOT set # to reference the absolute document root", () => {
53 validate({
54 newRoot: {
55 name: "test",
56 recurse: {
57 newRoot: {
58 name: "test2",
59 },
60 },
61 },
62 }).should.equal(false)
63 })
64 })