Skip to content

Commit cbbdc7a

Browse files
refactor: initialise testing of the names edit form
1 parent 3720cd2 commit cbbdc7a

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import "@testing-library/jest-dom"
2+
import { renderWithRedux } from "../../../__mocks__/renderWithRedux"
3+
import EditProfile from "@/components/popups/profile-settings/NamesForm"
4+
import { screen } from "@testing-library/react"
5+
6+
jest.mock("next/router", () => ({
7+
useRouter: () => ({
8+
push: jest.fn(),
9+
events: {
10+
on: jest.fn(),
11+
off: jest.fn(),
12+
emit: jest.fn(),
13+
},
14+
isFallback: false,
15+
pathname: "mocked-pathname",
16+
}),
17+
}));
18+
const handleClose = jest.fn()
19+
describe("NamesForm", () => {
20+
it("should render the names edit form", () => {
21+
renderWithRedux(<EditProfile show onClose={handleClose} />)
22+
const form = screen.getByTestId('names-edit-form')
23+
expect(form).toBeInTheDocument()
24+
})
25+
})

src/components/popups/profile-settings/EmailForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default function EditEmail({ show, onClose }: EditProfileProps): ReactEle
103103
required: "This field is required",
104104
pattern: {
105105
value: /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/i,
106-
message: "This must be a valid email address -",
106+
message: "This must be a valid email address",
107107
},
108108
minLength: {
109109
value: 2,

src/components/popups/profile-settings/NamesForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function EditProfile({ show, onClose }: EditProfileProps): ReactE
6767
<Modal show={show} onClose={onClose}>
6868
<div className="px-6 pt-6 relative">
6969
<h1 className="text-.5xl leading-none font-medium mb-12">{t("profile.settings.edit.name.update")}</h1>
70-
<form onSubmit={handleSubmit(onSave)}>
70+
<form onSubmit={handleSubmit(onSave)} data-testid="names-edit-form">
7171
<div className="mb-2.5">
7272
<Input
7373
label={`${t("profile.edit.label.fist-name")}`}

src/components/popups/profile-settings/index.tsx

Whitespace-only changes.

0 commit comments

Comments
 (0)