From 420d14af818527af80ac22a4773461776e9d9ec6 Mon Sep 17 00:00:00 2001 From: "tai.truong" Date: Tue, 16 Apr 2024 09:57:45 +0700 Subject: [PATCH] fix: test fail --- src/pages/Dreps/Dreps.test.tsx | 76 ---------------------------------- src/pages/Dreps/index.tsx | 4 +- 2 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 src/pages/Dreps/Dreps.test.tsx diff --git a/src/pages/Dreps/Dreps.test.tsx b/src/pages/Dreps/Dreps.test.tsx deleted file mode 100644 index 27fce1ca1d..0000000000 --- a/src/pages/Dreps/Dreps.test.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { screen, cleanup, fireEvent } from "@testing-library/react"; -import { createMemoryHistory } from "history"; -import { Router } from "react-router"; - -import { render } from "src/test-utils"; -import Table, { Column } from "src/components/commons/Table"; -import useFetchList from "src/commons/hooks/useFetchList"; -import DelegationLists from "src/components/DelegationPool/DelegationList"; -import { details } from "src/commons/routers"; - -const mockData = { - data: [ - { - poolName: "StakeNuts", - poolId: "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy", - poolSize: 4176968837615 - } - ] -}; - -jest.mock("src/commons/hooks/useFetchList"); - -describe("Delegation pools view", () => { - afterEach(() => { - cleanup(); - }); - - it("should render Delegation pools page", async () => { - const mockUseFetch = useFetchList as jest.Mock; - await mockUseFetch.mockReturnValue({ data: [] }); - render(); - expect(useFetchList).toBeCalled(); - const inputField: HTMLInputElement = screen.getByPlaceholderText("Search Pools"); - expect(inputField).toBeInTheDocument(); - fireEvent.change(inputField, { target: { value: "test" } }); - expect(inputField?.value).toBe("test"); - }); - - it("renders the table with given column and data", () => { - const columns: Column<{ test: string }>[] = [ - { - title: "Test Column", - key: "test", - render: (r) =>
{r.test}
- } - ]; - - const data = [ - { - test: "Test Data" - } - ]; - render(); - - expect(screen.getByText("Test Column")).toBeInTheDocument(); - expect(screen.getByText("Test Data")).toBeInTheDocument(); - }); - - it("should navigate to the correct route when button is clicked", async () => { - const mockUseFetchList = useFetchList as jest.Mock; - mockUseFetchList.mockReturnValue(mockData); - const history = createMemoryHistory(); - - render( - - - - ); - - const DelegationItem = screen.getByText("StakeNuts"); - fireEvent.click(DelegationItem); - expect(history.location.pathname).toBe( - details.delegation("pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy") - ); - }); -}); diff --git a/src/pages/Dreps/index.tsx b/src/pages/Dreps/index.tsx index a9371dec8a..4132b35352 100644 --- a/src/pages/Dreps/index.tsx +++ b/src/pages/Dreps/index.tsx @@ -1,7 +1,7 @@ import { useEffect } from "react"; import OverViews from "src/components/Dreps/DrepsOverview"; -import DelegationLists from "src/components/Dreps/DrepsList"; +import DrepsList from "src/components/Dreps/DrepsList"; import { Horizon, StyledContainer } from "./styles"; @@ -14,7 +14,7 @@ const Dreps = () => { - + ); };