Debian Codegraph @

spec/issues/815_id_updates_ref_base.spec.ts

raw symbols ◀ ▶ SCIP
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 // @ts-ignore
41 }).should.equal(true)
42
43 validate({
44 newRoot: {
45 name: "test",
46 recurse: {
47 name: "test2",
48 },
49 },
•50 // @ts-ignore
51 }).should.equal(true)
52 })
53
54 it("should NOT set # to reference the absolute document root", () => {
55 validate({
56 newRoot: {
57 name: "test",
58 recurse: {
59 newRoot: {
60 name: "test2",
61 },
62 },
63 },
•64 // @ts-ignore
65 }).should.equal(false)
66 })
67 })