Skip to content

Commit

Permalink
[fix] tests for pagination using testing classnames
Browse files Browse the repository at this point in the history
  • Loading branch information
shellyear authored and blcham committed May 13, 2024
1 parent f666400 commit eda8aa5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/components/misc/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ const Pagination = ({ pageNumber, handlePagination, itemCount, pageCount, allowS
<>
<div className="d-flex justify-content-center">
<BSPagination>
<BSPagination.First disabled={pageNumber === INITIAL_PAGE} onClick={() => handlePagination(INITIAL_PAGE)} />
<BSPagination.Prev disabled={pageNumber === INITIAL_PAGE} onClick={() => handlePagination(pageNumber - 1)} />
<BSPagination.First
className="test-pag-arrow"
disabled={pageNumber === INITIAL_PAGE}
onClick={() => handlePagination(INITIAL_PAGE)}
/>
<BSPagination.Prev
className="test-pag-arrow"
disabled={pageNumber === INITIAL_PAGE}
onClick={() => handlePagination(pageNumber - 1)}
/>
{generatePageNumbers().map((pageNum, i) => {
if (pageNum === "...") {
return <BSPagination.Ellipsis key={i} />;
Expand All @@ -80,7 +88,11 @@ const Pagination = ({ pageNumber, handlePagination, itemCount, pageCount, allowS
{pageCount + 1}
</BSPagination.Item>
)}
<BSPagination.Next disabled={pageNumber >= pageCount} onClick={() => handlePagination(pageNumber + 1)} />
<BSPagination.Next
className="test-pag-arrow"
disabled={pageNumber >= pageCount}
onClick={() => handlePagination(pageNumber + 1)}
/>
</BSPagination>
</div>
{allowSizeChange && (
Expand Down
4 changes: 2 additions & 2 deletions tests/__tests__/components/Pagination.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Pagination", function () {
);
const pagination = TestUtils.findRenderedDOMComponentWithClass(tree, "pagination");
expect(pagination).not.toBeNull();
const li = TestUtils.scryRenderedDOMComponentsWithTag(tree, "li");
expect(li.length).toEqual(4);
const li = TestUtils.scryRenderedDOMComponentsWithClass(tree, "test-pag-arrow");
expect(li.length).toEqual(3);
});
});

0 comments on commit eda8aa5

Please sign in to comment.