Skip to content

Commit

Permalink
[Issue #3522] Do not show pagination on search when no search results…
Browse files Browse the repository at this point in the history
… returned. (#3524)
  • Loading branch information
yebra06 authored Jan 15, 2025
1 parent 7540a19 commit e22d602
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/components/search/SearchPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function SearchPagination({

return (
<div className={`grants-pagination ${loading ? "disabled" : ""}`}>
{pages > 0 && (
{totalResults !== "0" && pages > 0 && (
<Pagination
pathname="/search"
totalPages={pages}
Expand Down
20 changes: 20 additions & 0 deletions frontend/tests/components/search/SearchPagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,24 @@ describe("SearchPagination", () => {

expect(screen.queryByRole("navigation")).not.toBeInTheDocument();
});

it("Renders Pagination component when totalResults > 0", () => {
render(
<SearchPagination
totalResults={"1"}
page={1}
query={"test"}
total={10}
/>,
);

expect(screen.getByRole("navigation")).toBeInTheDocument();
});
it("Does not render Pagination component when total results is 0", () => {
render(
<SearchPagination page={1} query={"test"} totalResults={"0"} total={0} />,
);

expect(screen.queryByRole("navigation")).not.toBeInTheDocument();
});
});

0 comments on commit e22d602

Please sign in to comment.