Skip to content

Commit 07e83e4

Browse files
author
Stefan Terdell
committed
✅ Add test case for issue #16
1 parent dc45265 commit 07e83e4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/parseDef.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,14 @@ describe("Basic parsing", () => {
155155
expect(parsedSchema).toStrictEqual(expectedJsonSchema);
156156
expect(ajv.validateSchema(parsedSchema!)).toEqual(true);
157157
});
158+
159+
it("should handle a nullable string properly", () => {
160+
const shorthand = z.string().nullable();
161+
const union = z.union([z.string(), z.null()]);
162+
163+
const expected = { type: ["string", "null"] };
164+
165+
expect(parseDef(shorthand._def, new References())).toStrictEqual(expected);
166+
expect(parseDef(union._def, new References())).toStrictEqual(expected);
167+
});
158168
});

0 commit comments

Comments
 (0)