diff --git a/test/useFormo.test.ts b/test/useFormo.test.ts index 770f716..04f59c4 100644 --- a/test/useFormo.test.ts +++ b/test/useFormo.test.ts @@ -32,19 +32,23 @@ describe("formo", () => { }); test("it works when resetting the form", () => { - const { result } = renderHook(() => - useFormo( - { - initialValues: { - city: "Milan", - zipCode: "20100", + const { result, rerender } = renderHook( + (initialValues) => + useFormo( + { + initialValues, + fieldValidators: () => ({}), }, - fieldValidators: () => ({}), + { + onSubmit: () => Promise.resolve(success(null)), + } + ), + { + initialProps: { + city: "Milan", + zipCode: "20100", }, - { - onSubmit: () => Promise.resolve(success(null)), - } - ) + } ); act(() => { @@ -52,6 +56,11 @@ describe("formo", () => { result.current.fieldProps("zipCode").onChange(""); }); + rerender({ + city: "Rome", + zipCode: "", + }); + expect(result.current.fieldProps("city").value).toBe("Rome"); expect(result.current.fieldProps("zipCode").value).toBe("");