Skip to content

Commit c85ef0f

Browse files
committed
test: added test case for #4186
1 parent 9f1c63b commit c85ef0f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/zod/tests/zod.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,33 @@ test('uses zod default values for initial values', async () => {
294294
})
295295
);
296296
});
297+
298+
// #4186
299+
test('default values should not be undefined', async () => {
300+
const initialSpy = jest.fn();
301+
mountWithHoc({
302+
setup() {
303+
const schema = toTypedSchema(
304+
zod.object({
305+
email: zod.string().min(1),
306+
})
307+
);
308+
309+
const { values } = useForm({
310+
validationSchema: schema,
311+
});
312+
313+
// submit now
314+
initialSpy(values);
315+
316+
return {
317+
schema,
318+
};
319+
},
320+
template: `<div></div>`,
321+
});
322+
323+
await flushPromises();
324+
await expect(initialSpy).toHaveBeenCalledTimes(1);
325+
await expect(initialSpy).toHaveBeenLastCalledWith(expect.objectContaining({}));
326+
});

0 commit comments

Comments
 (0)