CF-11 testing login page
This commit is contained in:
31
src/core/components/PasswordField/__test__/index.test.js
Normal file
31
src/core/components/PasswordField/__test__/index.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import {fireEvent, getByRole, render, screen} from "@testing-library/react";
|
||||
import PasswordField from "@/core/components/PasswordField";
|
||||
import {Formik} from "formik";
|
||||
|
||||
describe('Password Field component in core folder', () => {
|
||||
describe('Rendering', () => {
|
||||
it('Show password when visibility icon clicked',() => {
|
||||
render (
|
||||
<Formik initialValues={{password:''}} onSubmit={()=>{}}>
|
||||
{(props)=>(
|
||||
<PasswordField label="رمز عبور" />
|
||||
)}
|
||||
</Formik>
|
||||
)
|
||||
|
||||
const iconElement = screen.getByLabelText("رمز عبور")
|
||||
const iconButton = screen.getByRole("button")
|
||||
|
||||
|
||||
expect(iconElement).toHaveAttribute('type', 'password');
|
||||
|
||||
fireEvent.click(iconButton);
|
||||
|
||||
expect(iconElement).toHaveAttribute("type", "text");
|
||||
|
||||
fireEvent.click(iconButton);
|
||||
|
||||
expect(iconElement).toHaveAttribute('type', 'password');
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user