-
-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathbundle-no-optimize.spec.ts
More file actions
26 lines (22 loc) · 1.12 KB
/
bundle-no-optimize.spec.ts
File metadata and controls
26 lines (22 loc) · 1.12 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
import { describe, it, expect } from "vitest";
import $RefParser from "../../../lib/index.js";
import path from "../../utils/path.js";
describe("bundle.optimizeInternalRefs option (issue #392)", () => {
it("should optimize internal ref chains by default", async () => {
const parser = new $RefParser();
const bundled = await parser.bundle(path.rel("test/specs/bundle-no-optimize/root.json"));
// By default, fixRefsThroughRefs optimizes the chain:
// item -> #/definitions/extended -> #/definitions/base
// becomes: item -> #/definitions/base (skipping intermediate)
expect(bundled.properties.item.$ref).toBe("#/definitions/base");
});
it("should preserve internal ref chains when optimizeInternalRefs is false", async () => {
const parser = new $RefParser();
const bundled = await parser.bundle(path.rel("test/specs/bundle-no-optimize/root.json"), {
bundle: { optimizeInternalRefs: false },
});
// With optimization disabled, the original chain is preserved:
// item still points to #/definitions/extended
expect(bundled.properties.item.$ref).toBe("#/definitions/extended");
});
});