Skip to content

Commit 6b6face

Browse files
committed
union of literal zod test
1 parent 32f419d commit 6b6face

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,3 +1069,11 @@ test("convexToZod optional values", () => {
10691069

10701070
expect(roundTripOptionalArray.isOptional).toBe("optional");
10711071
});
1072+
1073+
test("convexToZod union of one literal", () => {
1074+
const unionValidator = v.union(v.literal("hello"));
1075+
const zodUnion = convexToZod(unionValidator);
1076+
expect(zodUnion.constructor.name).toBe("ZodUnion");
1077+
expect(zodUnion.parse("hello")).toBe("hello");
1078+
expect(() => zodUnion.parse("world")).toThrow();
1079+
});

0 commit comments

Comments
 (0)