forked from APIDevTools/json-schema-ref-parser
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcircular-external-direct.spec.ts
More file actions
33 lines (31 loc) · 1.29 KB
/
Copy pathcircular-external-direct.spec.ts
File metadata and controls
33 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { describe, it } from "vitest";
import { expect } from "vitest";
import $RefParser from "../../../lib/index.js";
import path from "../../utils/path.js";
import parsedSchema from "./parsed.js";
import dereferencedSchema from "./dereferenced.js";
describe("Schema with direct circular (recursive) external $refs", () => {
it("should parse successfully", async () => {
const parser = new $RefParser();
const schema = await parser.parse(
path.rel("test/specs/circular-external-direct/circular-external-direct-root.yaml"),
);
expect(schema).to.equal(parser.schema);
expect(parser.$refs.paths()).to.deep.equal([
path.abs("test/specs/circular-external-direct/circular-external-direct-root.yaml"),
]);
// The "circular" flag should NOT be set
// (it only gets set by `dereference`)
expect(parser.$refs.circular).to.equal(false);
});
it("should dereference successfully", async () => {
const parser = new $RefParser();
const schema = await parser.dereference(
path.rel("test/specs/circular-external-direct/circular-external-direct-root.yaml"),
);
expect(schema).to.equal(parser.schema);
expect(schema).to.deep.equal(dereferencedSchema);
// The "circular" flag should be set
expect(parser.$refs.circular).to.equal(false);
});
});