Skip to content

Commit f340b09

Browse files
committed
union of literal object zod test
1 parent 6b6face commit f340b09

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/convex-helpers/server/zod.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,3 +1077,13 @@ test("convexToZod union of one literal", () => {
10771077
expect(zodUnion.parse("hello")).toBe("hello");
10781078
expect(() => zodUnion.parse("world")).toThrow();
10791079
});
1080+
1081+
test("convexToZod object with union of one literal", () => {
1082+
const unionValidator = v.object({
1083+
member: v.union(v.literal("hello")),
1084+
});
1085+
const zodUnion = convexToZod(unionValidator);
1086+
expect(zodUnion.constructor.name).toBe("ZodObject");
1087+
expect(zodUnion.parse({ member: "hello" })).toEqual({ member: "hello" });
1088+
expect(() => zodUnion.parse({ member: "world" })).toThrow();
1089+
});

0 commit comments

Comments
 (0)