59 lines · 1.2 KB · TypeScript
RawDownload
import { describe, expect, it } from "@effect/vitest"; import { collectReferencedDefinitions } from "./schema-refs"; describe("schema-refs", () => {  it("collects only transitive definitions reachable from schema roots", () => {    const defs = new Map<string, unknown>([      [        "Pet",        {          anyOf: [{ $ref: "#/$defs/Dog" }, { $ref: "#/$defs/Cat" }],        },      ],      [        "Dog",        {          type: "object",          properties: {            collar: { $ref: "#/$defs/Collar" },          },        },      ],      [        "Cat",        {          type: "object",          properties: {            lives: { type: "number" },          },        },      ],      [        "Collar",        {          type: "object",          properties: {            id: { type: "string" },          },        },      ],      [        "Unused",        {          type: "object",          properties: {            value: { type: "string" },          },        },      ],    ]);     expect(collectReferencedDefinitions([{ $ref: "#/$defs/Pet" }], defs)).toEqual({      Cat: defs.get("Cat"),      Collar: defs.get("Collar"),      Dog: defs.get("Dog"),      Pet: defs.get("Pet"),    });  });});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t