Skip to content

Commit 9c56bb6

Browse files
committed
A test for that error.
1 parent 03b7af3 commit 9c56bb6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

zod-plugin/tests/runtime.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ describe("Zod Runtime Plugin", () => {
117117
},
118118
);
119119

120+
test("throws when multiple source keys map to the same target", () => {
121+
const schema = z.object({ a: z.number(), b: z.string() });
122+
expect(() => schema.remap({ a: "x", b: "x" })).toThrowError(
123+
/duplicate target keys/,
124+
);
125+
});
126+
120127
test("should support a mapping function", () => {
121128
const schema = z.object({ user_id: z.string(), name: z.string() });
122129
const mappedSchema = schema.remap((shape) => camelize(shape, true));

0 commit comments

Comments
 (0)