Skip to content

Commit

Permalink
WILD_011 - Fix : test reparation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellana33 committed Aug 23, 2024
1 parent c7210a4 commit d080677
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions front/src/__tests__/UrlHistory.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect, vi } from "vitest";
import UrlHistory from "../pages/UrlHistory";
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from "react-router-dom";
import { MockedProvider } from "@apollo/client/testing";
import { GET_ONE_URL } from "@/graphql/queries";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
Expand All @@ -27,7 +27,7 @@ describe("Tests UrlHistory", () => {
delay: 30,
request: {
query: GET_ONE_URL,
variable: {
variables: {
urlId: "3312231f-020b-47b1-9fd5-f3747e8bc782",
},
},
Expand Down Expand Up @@ -85,7 +85,7 @@ describe("Tests UrlHistory", () => {
delay: 30,
request: {
query: GET_ONE_URL,
variable: {
variables: {
urlId: "3312231f-020b-47b1-9fd5-f3747e8bc782",
},
},
Expand All @@ -106,10 +106,9 @@ describe("Tests UrlHistory", () => {

it("Should display without histories", async () => {
const urlMock = {
delay: 30,
request: {
query: GET_ONE_URL,
variable: {
variables: {
urlId: "3312231f-020b-47b1-9fd5-f3747e8bc782",
},
},
Expand All @@ -122,21 +121,23 @@ describe("Tests UrlHistory", () => {
histories: [],
},
},
loading: true,
},
};

render(
<MockedProvider mocks={[urlMock]} addTypename={false}>
<MemoryRouter>
<UrlHistory />
</MemoryRouter>
</MockedProvider>,
);
expect(await screen.findByText("En attente...")).toBeInTheDocument();
const historiesContainer = await screen.findByTestId(
"histories-container",
);
expect(historiesContainer.children).toHaveLength(0);

await waitFor(() => {
expect(screen.queryByText("En attente...")).not.toBeInTheDocument();
});

const historiesContainer = screen.queryByTestId("histories-container");
expect(historiesContainer).toBeInTheDocument();
});
it("Should render the 'Lancer une analyse' button", async () => {
const urlMock = {
Expand Down

0 comments on commit d080677

Please sign in to comment.