Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien0102 committed Jul 20, 2021
1 parent 6ab3313 commit b94cff0
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/scripts/tests/import-open-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,25 @@ describe("scripts/import-open-api", () => {
};
expect(getArray(item)).toEqual("(Foo & Bar & Baz)[]");
});
it("should return an array of anyOf", () => {
const item = {
items: {
anyOf: [
{
$ref: "#/components/schemas/foo",
},
{
$ref: "#/components/schemas/bar",
},
{
$ref: "#/components/schemas/baz",
},
],
},
type: "array",
};
expect(getArray(item)).toEqual("(Foo | Bar | Baz)[]");
});
});

describe("getObject", () => {
Expand Down Expand Up @@ -352,6 +371,27 @@ describe("scripts/import-open-api", () => {
`);
});

it("should deal with anyOf", () => {
const item = {
type: "object",
anyOf: [
{ $ref: "#/components/schemas/foo" },
{
type: "object",
required: ["name"],
properties: {
name: { type: "string" },
},
},
],
};
expect(getObject(item)).toMatchInlineSnapshot(`
"Foo | {
name: string;
}"
`);
});

it("should deal with allOf and required at root level", () => {
const item = {
type: "object",
Expand Down Expand Up @@ -781,7 +821,7 @@ describe("scripts/import-open-api", () => {
`);
});

it("should declare a a type for union object", () => {
it("should declare a type for union object", () => {
const responses: ComponentsObject["responses"] = {
JobRun: {
description: "Job is starting",
Expand Down

0 comments on commit b94cff0

Please sign in to comment.