write some behavioral test and rendered test for create form component
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import CenterLayout from "@/layouts/CenterLayout";
|
||||
import DashboardLayouts from "@/layouts/dashboardLayouts";
|
||||
import DashboardLayouts from "@/layouts/DashboardLayout";
|
||||
import {Button, Container, Paper, Stack, Typography,} from "@mui/material";
|
||||
import {Formik} from "formik";
|
||||
import * as Yup from "yup";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import CenterLayout from "@/layouts/CenterLayout";
|
||||
import DashboardLayouts from "@/layouts/dashboardLayouts";
|
||||
import DashboardLayouts from "@/layouts/DashboardLayout";
|
||||
import useUser from "@/lib/app/hooks/useUser";
|
||||
import {Box, Container, Grid, Paper, Stack, TextField, Typography,} from "@mui/material";
|
||||
import * as Yup from "yup";
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
const CreateContent = () => {
|
||||
return (
|
||||
<>
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default CreateContent
|
||||
@@ -1,18 +1,31 @@
|
||||
import {render, screen} from "@testing-library/react";
|
||||
import MockAppWithProviders from "../../../../../../mocks/AppWithProvider";
|
||||
import {fireEvent, render, screen} from "@testing-library/react";
|
||||
import React, {useState} from 'react';
|
||||
import MockAppWithProviders from "../../../../../../../mocks/AppWithProvider";
|
||||
import CreateForm from "../../CreateForm";
|
||||
|
||||
jest.spyOn(React, 'useState');
|
||||
|
||||
describe("CreateForm Component From Expert Management", () => {
|
||||
describe("Rendering", () => {
|
||||
it("Create Button Rendered", () => {
|
||||
render(<MockAppWithProviders><CreateForm/></MockAppWithProviders>);
|
||||
const versionControler = screen.queryByTitle("ثبت کارشناس");
|
||||
expect(versionControler).toBeInTheDocument();
|
||||
const CreateButton = screen.getByRole('button', {name: "افزودن کارشناس"});
|
||||
expect(CreateButton).toBeInTheDocument();
|
||||
});
|
||||
it("Dialog Header Rendered", () => {
|
||||
render(<MockAppWithProviders><CreateForm/></MockAppWithProviders>);
|
||||
const versionControler = screen.queryByText("ثبت کارشناس");
|
||||
expect(versionControler).toBeInTheDocument();
|
||||
const CreateDialogHeader = screen.queryByText("افزودن کارشناس");
|
||||
expect(CreateDialogHeader).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
describe("Behavioral", () => {
|
||||
it("by Clicking Create Button Dialog State Should Change (true/false)", () => {
|
||||
const setOpenCreateDialogMock = jest.fn();
|
||||
useState.mockReturnValue([false, setOpenCreateDialogMock]);
|
||||
render(<MockAppWithProviders><CreateForm/></MockAppWithProviders>);
|
||||
const CreateButton = screen.getByRole('button', {name: "افزودن کارشناس"});
|
||||
fireEvent.click(CreateButton);
|
||||
expect(setOpenCreateDialogMock).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,13 @@
|
||||
const Create = () => {
|
||||
import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material";
|
||||
import {useTranslations} from "next-intl";
|
||||
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
||||
import {useState} from "react";
|
||||
import CreateContent from "./CreateContent";
|
||||
|
||||
const Create = ({mutate, fetchUrl}) => {
|
||||
const t = useTranslations();
|
||||
const [openCreateDialog, setOpenCreateDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import DashboardLayouts from "@/layouts/dashboardLayouts";
|
||||
import DashboardLayouts from "@/layouts/DashboardLayout";
|
||||
|
||||
const DashboardFirstComponent = () => {
|
||||
return <DashboardLayouts></DashboardLayouts>;
|
||||
|
||||
Reference in New Issue
Block a user