Skip to content

Commit

Permalink
update test to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
giogonzo committed Feb 11, 2022
1 parent d2003e5 commit 2eda48d
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions test/useFormo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,35 @@ 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(() => {
result.current.fieldProps("city").onChange("Rome");
result.current.fieldProps("zipCode").onChange("");
});

rerender({
city: "Rome",
zipCode: "",
});

expect(result.current.fieldProps("city").value).toBe("Rome");
expect(result.current.fieldProps("zipCode").value).toBe("");

Expand Down

0 comments on commit 2eda48d

Please sign in to comment.