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

Commit

Permalink
typing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
btabaska committed Aug 23, 2024
1 parent 8ce9d40 commit 82e9a40
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions frontend/tests/components/search/SearchPagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import "@testing-library/jest-dom/extend-expect";
import { render, screen } from "@testing-library/react";
import { axe } from "jest-axe";
import React from "react";
import { QueryContext } from "src/app/[locale]/search/QueryProvider";
import SearchPagination from "src/components/search/SearchPagination";

// Mock the useSearchParamUpdater hook
Expand All @@ -13,33 +12,12 @@ jest.mock("src/hooks/useSearchParamUpdater", () => ({
}),
}));

const mockUpdateTotalPages = jest.fn();
const mockUpdateTotalResults = jest.fn();

interface SearchPaginationProps {
page: number;
query: string;
total?: number | null;
loading?: boolean;
}

beforeEach(() => {
jest.clearAllMocks();
});

const renderComponent = (props: SearchPaginationProps) => {
return render(
<QueryContext.Provider
value={{
updateTotalPages: mockUpdateTotalPages,
updateTotalResults: mockUpdateTotalResults,
totalPages: props.total || 1,
}}
>
<SearchPagination {...props} />
</QueryContext.Provider>,
);
};


describe("SearchPagination", () => {
beforeEach(() => {
Expand Down Expand Up @@ -68,16 +46,4 @@ describe("SearchPagination", () => {

expect(screen.queryByRole("navigation")).not.toBeInTheDocument();
});
it("disables pagination when loading", () => {
renderComponent({
page: 1,
query: "test",
total: 5,
loading: true,
});
expect(screen.getByText("Next").closest("div")).toHaveStyle(
"pointer-events: none",
);
expect(screen.getByText("Next").closest("div")).toHaveStyle("opacity: 0.5");
});
});

0 comments on commit 82e9a40

Please sign in to comment.