Skip to content

Commit 03c6532

Browse files
refactor: add case for the form validation
1 parent 0f7aae5 commit 03c6532

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

__tests__/components/popus/EmailForm.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ describe("EmailEditForm", () => {
6363
})
6464
});
6565

66+
it("should not submit the form when emails do not match", async () => {
67+
const emailInput = screen.getByPlaceholderText('login-page.email.placeholder');
68+
const emailInputConfirm = screen.getByPlaceholderText('profile.settings.edit.email.confirm');
69+
const form = screen.getByTestId('edit-email-form');
70+
71+
fireEvent.change(emailInput, { target: { value: "[email protected]" } });
72+
fireEvent.change(emailInputConfirm, { target: { value: "[email protected]" } });
73+
74+
await act(async () => {
75+
fireEvent.submit(form);
76+
});
77+
78+
expect(onSubmit).not.toHaveBeenCalled();
79+
expect(screen.queryByText("Emails should match.")).toBeInTheDocument();
80+
81+
})
82+
6683
it("it should close the modal when its open", () => {
6784
expect(screen.getByTestId('profileModal')).toBeInTheDocument()
6885
fireEvent.click(screen.getByTestId('close-button'))

0 commit comments

Comments
 (0)