Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
MAT-7576: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips committed Oct 2, 2024
1 parent bd84faa commit d159e16
Showing 1 changed file with 46 additions and 13 deletions.
59 changes: 46 additions & 13 deletions src/components/createTestCase/CreateNewTestCaseDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CreateNewTestCaseDialog from "./CreateNewTestCaseDialog";
import { Measure } from "@madie/madie-models";
import axios from "../../api/axios-instance";
import { specialChars } from "../../util/checkSpecialCharacters";
import { MemoryRouter } from "react-router-dom";

jest.mock("../../api/axios-instance");
const mockedAxios = axios as jest.Mocked<typeof axios>;
Expand Down Expand Up @@ -39,10 +40,18 @@ describe("Create New Test Case Dialog", () => {
jest.clearAllMocks();
});

const mockMeasure = { ...formikInfo, id: "test-id" };

test("should render all the fields in the test case creation form", async () => {
await act(async () => {
const { findByTestId } = await render(
<CreateNewTestCaseDialog open={true} onClose={undefined} />
<MemoryRouter
initialEntries={[
`/measures/${mockMeasure.id}/edit/test-cases/list-page`,
]}
>
<CreateNewTestCaseDialog open={true} onClose={undefined} />
</MemoryRouter>
);

expect(await findByTestId("create-test-case-title")).toBeInTheDocument();
Expand All @@ -64,7 +73,13 @@ describe("Create New Test Case Dialog", () => {
test("Save button should not be enabled when required field is empty", async () => {
await act(async () => {
const { getByTestId } = await render(
<CreateNewTestCaseDialog open={true} onClose={undefined} />
<MemoryRouter
initialEntries={[
`/measures/${mockMeasure.id}/edit/test-cases/list-page`,
]}
>
<CreateNewTestCaseDialog open={true} onClose={undefined} />
</MemoryRouter>
);

const titleInput = await getByTestId("create-test-case-title-input");
Expand Down Expand Up @@ -96,11 +111,17 @@ describe("Create New Test Case Dialog", () => {
} as unknown as Measure;
await act(async () => {
const { getByRole, getByTestId, getByText, queryByTestId } = await render(
<CreateNewTestCaseDialog
open={true}
onClose={jest.fn()}
measure={measure}
/>
<MemoryRouter
initialEntries={[
`/measures/${mockMeasure.id}/edit/test-cases/list-page`,
]}
>
<CreateNewTestCaseDialog
open={true}
onClose={jest.fn()}
measure={measure}
/>
</MemoryRouter>
);

const titleInput = await getByTestId("create-test-case-title-input");
Expand Down Expand Up @@ -143,7 +164,13 @@ describe("Create New Test Case Dialog", () => {

await act(async () => {
const { getByRole, getByTestId, getByText, queryByTestId } = await render(
<CreateNewTestCaseDialog open={true} onClose={jest.fn()} />
<MemoryRouter
initialEntries={[
`/measures/${mockMeasure.id}/edit/test-cases/list-page`,
]}
>
<CreateNewTestCaseDialog open={true} onClose={jest.fn()} />
</MemoryRouter>
);

const titleInput = await getByTestId("create-test-case-title-input");
Expand Down Expand Up @@ -196,11 +223,17 @@ describe("Create New Test Case Dialog", () => {
} as unknown as Measure;
await act(async () => {
const { getByRole, getByTestId, getByText, queryByTestId } = await render(
<CreateNewTestCaseDialog
open={true}
onClose={jest.fn()}
measure={measure}
/>
<MemoryRouter
initialEntries={[
`/measures/${mockMeasure.id}/edit/test-cases/list-page`,
]}
>
<CreateNewTestCaseDialog
open={true}
onClose={jest.fn()}
measure={measure}
/>
</MemoryRouter>
);

const titleInput = await getByTestId("create-test-case-title-input");
Expand Down

0 comments on commit d159e16

Please sign in to comment.