Skip to content

Commit a22988a

Browse files
committed
chore: check for reset outside of submit
1 parent f674014 commit a22988a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/react-form/tests/useForm.test.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,9 @@ it('form should reset when rendered correctly - react', async () => {
803803
name: '',
804804
},
805805
onSubmit: ({ value }) => {
806-
expect(value).toEqual({ name: 'test' })
806+
expect(value).toEqual({ name: 'another-test' })
807807

808-
form.reset({ name: 'test' })
808+
form.reset(value)
809809
},
810810
})
811811

@@ -830,18 +830,26 @@ it('form should reset when rendered correctly - react', async () => {
830830
>
831831
submit
832832
</button>
833+
834+
<button type="button" onClick={() => form.reset()} data-testid="reset">
835+
reset
836+
</button>
833837
</div>
834838
)
835839
}
836840

837841
const { getByTestId } = render(<Comp />)
838842
const input = getByTestId('fieldinput')
839843
const submit = getByTestId('submit')
844+
const reset = getByTestId('reset')
840845

841846
await user.type(input, 'test')
842847
await waitFor(() => expect(input).toHaveValue('test'))
843848

844-
await user.click(submit)
849+
await user.click(reset)
850+
await waitFor(() => expect(input).toHaveValue(''))
845851

846-
await waitFor(() => expect(input).toHaveValue('test'))
852+
await user.type(input, 'another-test')
853+
await user.click(submit)
854+
await waitFor(() => expect(input).toHaveValue('another-test'))
847855
})

0 commit comments

Comments
 (0)