diff --git a/frontend/src/components/search/SearchPagination.tsx b/frontend/src/components/search/SearchPagination.tsx
index b69971863..da1b209a0 100644
--- a/frontend/src/components/search/SearchPagination.tsx
+++ b/frontend/src/components/search/SearchPagination.tsx
@@ -42,17 +42,19 @@ export default function SearchPagination({
return (
-
updatePage(page + 1)}
- onClickPrevious={() => updatePage(page > 1 ? page - 1 : 0)}
- onClickPageNumber={(event: React.MouseEvent, page: number) =>
- updatePage(page)
- }
- />
+ {pages > 0 && (
+ updatePage(page + 1)}
+ onClickPrevious={() => updatePage(page > 1 ? page - 1 : 0)}
+ onClickPageNumber={(event: React.MouseEvent, page: number) =>
+ updatePage(page)
+ }
+ />
+ )}
);
}
diff --git a/frontend/tests/components/search/SearchPagination.test.tsx b/frontend/tests/components/search/SearchPagination.test.tsx
index bfbd28b0c..40f4b443f 100644
--- a/frontend/tests/components/search/SearchPagination.test.tsx
+++ b/frontend/tests/components/search/SearchPagination.test.tsx
@@ -1,29 +1,26 @@
-/* eslint-disable jest/no-commented-out-tests */
+/* eslint-disable testing-library/no-node-access */
import "@testing-library/jest-dom/extend-expect";
+import { render, screen } from "@testing-library/react";
import { axe } from "jest-axe";
-import { render } from "tests/react-utils";
import React from "react";
import SearchPagination from "src/components/search/SearchPagination";
-const mockUpdateQueryParams = jest.fn();
-
+// Mock the useSearchParamUpdater hook
jest.mock("src/hooks/useSearchParamUpdater", () => ({
useSearchParamUpdater: () => ({
- updateQueryParams: mockUpdateQueryParams,
+ updateQueryParams: jest.fn(),
}),
}));
-// import SearchPagination, {
-// PaginationPosition,
-// } from "../../../src/components/search/SearchPagination";
-
-// import { render } from "@testing-library/react";
+beforeEach(() => {
+ jest.clearAllMocks();
+});
-// TODO (Issue #1936): Uncomment tests after React 19 upgrade
describe("SearchPagination", () => {
- it("pass test", () => {
- expect(1).toBe(1);
+ beforeEach(() => {
+ jest.clearAllMocks();
});
+
it("should not have basic accessibility issues", async () => {
const { container } = render();
@@ -36,73 +33,14 @@ describe("SearchPagination", () => {
});
expect(results).toHaveNoViolations();
});
+ it("Renders Pagination component when pages > 0", () => {
+ render();
- // it("renders hidden input when showHiddenInput is true", () => {
- // render(
- // ,
- // );
-
- // const hiddenInput = screen.getByTestId("hiddenCurrentPage");
- // expect(hiddenInput).toHaveValue("1");
- // });
-
- // it("does not render hidden input when showHiddenInput is false", () => {
- // render(
- // ,
- // );
- // expect(screen.queryByTestId("hiddenCurrentPage")).not.toBeInTheDocument();
- // });
-
- // it("calls handlePageChange with next page on next button click", () => {
- // render(
- // ,
- // );
- // fireEvent.click(screen.getByLabelText("Next page"));
- // expect(mockHandlePageChange).toHaveBeenCalledWith(page + 1);
- // });
-
- // it("calls handlePageChange with previous page on previous button click", () => {
- // render(
- // ,
- // );
- // fireEvent.click(screen.getByLabelText("Previous page"));
- // expect(mockHandlePageChange).toHaveBeenCalledWith(1);
- // });
+ expect(screen.getByRole("navigation")).toBeInTheDocument();
+ });
+ it("Does not render Pagination component when pages <= 0", () => {
+ render();
- // it("returns null when searchResultsLength is less than 1", () => {
- // const { container } = render(
- // ,
- // );
- // expect(container).toBeEmptyDOMElement();
- // });
+ expect(screen.queryByRole("navigation")).not.toBeInTheDocument();
+ });
});