write some behavioral test and rendered test for create form component
This commit is contained in:
6
src/core/components/DialogTransition.jsx
Normal file
6
src/core/components/DialogTransition.jsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import {forwardRef} from "react";
|
||||
import {Slide} from "@mui/material";
|
||||
|
||||
export const DialogTransition = forwardRef(function DialogTransition(props, ref) {
|
||||
return <Slide direction="up" ref={ref} {...props}/>;
|
||||
});
|
||||
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');
|
||||
})
|
||||
})
|
||||
})
|
||||
11
src/core/components/StyledFab.jsx
Normal file
11
src/core/components/StyledFab.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import {Fab, styled} from "@mui/material";
|
||||
|
||||
const StyledFab = styled(Fab)`
|
||||
position: absolute;
|
||||
bottom: 16px;
|
||||
/* @noflip */
|
||||
left: 16px;
|
||||
z-index: 1500;
|
||||
`;
|
||||
|
||||
export default StyledFab;
|
||||
@@ -36,4 +36,4 @@ const ErrorNotification = (t, status, message) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorNotification;
|
||||
export default ErrorNotification;
|
||||
@@ -9,4 +9,4 @@ const PendingNotification = (t) => {
|
||||
});
|
||||
};
|
||||
|
||||
export default PendingNotification;
|
||||
export default PendingNotification;
|
||||
@@ -39,4 +39,4 @@ const SuccessNotification = (t, status) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default SuccessNotification;
|
||||
export default SuccessNotification;
|
||||
@@ -35,4 +35,4 @@ const UploadFileNotification = (t) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default UploadFileNotification;
|
||||
export default UploadFileNotification;
|
||||
@@ -37,4 +37,4 @@ const WarningNotification = (t, status) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default WarningNotification;
|
||||
export default WarningNotification;
|
||||
@@ -1,7 +1,7 @@
|
||||
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL;
|
||||
|
||||
//login
|
||||
export const GET_USER_TOKEN = BASE_URL + "/dashboard/login";
|
||||
export const GET_USER_TOKEN = BASE_URL + "/api/auth/login";
|
||||
//end login
|
||||
|
||||
//change password
|
||||
@@ -9,7 +9,7 @@ export const SET_USER_PASSWORD = BASE_URL + "/dashboard/profile/change_password"
|
||||
//end change password
|
||||
|
||||
//user data
|
||||
export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info";
|
||||
export const GET_USER_ROUTE = BASE_URL + "/api/profile/info";
|
||||
//user data
|
||||
|
||||
//expert management
|
||||
|
||||
@@ -48,7 +48,7 @@ const isServerError = status => status >= 500 && status <= 599;
|
||||
const isClientError = status => status >= 400 && status <= 499;
|
||||
|
||||
const errorLogic = (response, t, notification) => {
|
||||
if (notification) ErrorNotification(t, response.status)
|
||||
if (notification) ErrorNotification(t, response.status, response.data.message)
|
||||
}
|
||||
const errorValidation = (response, t, notification) => {
|
||||
if (notification) {
|
||||
|
||||
Reference in New Issue
Block a user