Skip to content

Commit a7b6859

Browse files
committed
test: add failing tests for enums with type [string, null]
1 parent c732542 commit a7b6859

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/openapi-typescript/test/schema-object.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,19 @@ describe("Schema Object", () => {
278278
expect(generated).toBe("OneOf<[string, boolean, number, null]>");
279279
});
280280

281-
test("enum + polymorphism + nullable", () => {
282-
const generated = transformSchemaObject(
283-
{ type: ["string", "null"], enum: ["", "false positive", "won't fix", "used in tests"] },
284-
options
285-
);
286-
expect(generated).toBe(`"" | "false positive" | "won't fix" | "used in tests" | null`);
281+
test("enum + polymorphism + nullable 1", () => {
282+
const generated = transformSchemaObject({ type: ["string", "null"], enum: ["false positive", "won't fix", "used in tests"] }, options);
283+
expect(generated).toBe(`"false positive" | "won't fix" | "used in tests"`);
284+
});
285+
286+
test("enum + polymorphism + nullable 2", () => {
287+
const generated = transformSchemaObject({ type: ["string", "null"], enum: ["", "false positive", "won't fix", "used in tests"] }, options);
288+
expect(generated).toBe(`"" | "false positive" | "won't fix" | "used in tests"`);
289+
});
290+
291+
test("enum + polymorphism + nullable 3", () => {
292+
const generated = transformSchemaObject({ type: ["string", "null"], enum: [null, "false positive", "won't fix", "used in tests"] }, options);
293+
expect(generated).toBe(`null | "false positive" | "won't fix" | "used in tests"`);
287294
});
288295
});
289296
});

0 commit comments

Comments
 (0)