Skip to content

Commit 1ebab32

Browse files
committed
Fix pagination tests
1 parent 23fdc3c commit 1ebab32

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

site/src/components/PaginationWidget/PageButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const PageButton = ({
2929
aria-label={`${page === activePage ? "Current Page" : ""} ${
3030
page === numPages ? "Last Page" : ""
3131
} Page${page}`}
32-
name="Page button"
32+
name={page === undefined ? undefined : "Page button"}
3333
onClick={() => onPageClick && page && onPageClick(page)}
3434
disabled={disabled}
3535
>

site/src/components/PaginationWidget/PaginationWidget.test.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { screen } from "@testing-library/react"
22
import { render } from "../../testHelpers/renderHelpers"
33
import { PaginationWidget } from "./PaginationWidget"
4+
import { createPaginationRef } from "./utils"
45

56
describe("PaginatedList", () => {
67
it("displays an accessible previous and next button regardless of the number of pages", async () => {
78
const { container } = render(
89
<PaginationWidget
910
prevLabel="Previous"
1011
nextLabel="Next"
11-
onPrevClick={() => jest.fn()}
12-
onNextClick={() => jest.fn()}
12+
paginationRef={createPaginationRef({ page: 1, limit: 25 })}
1313
/>,
1414
)
1515

@@ -30,12 +30,8 @@ describe("PaginatedList", () => {
3030
<PaginationWidget
3131
prevLabel="Previous"
3232
nextLabel="Next"
33-
onPrevClick={() => jest.fn()}
34-
onNextClick={() => jest.fn()}
35-
onPageClick={(_) => jest.fn()}
3633
numRecords={200}
37-
numRecordsPerPage={12}
38-
activePage={1}
34+
paginationRef={createPaginationRef({ page: 1, limit: 12 })}
3935
/>,
4036
)
4137

@@ -50,12 +46,8 @@ describe("PaginatedList", () => {
5046
<PaginationWidget
5147
prevLabel="Previous"
5248
nextLabel="Next"
53-
onPrevClick={() => jest.fn()}
54-
onNextClick={() => jest.fn()}
55-
onPageClick={(_) => jest.fn()}
5649
numRecords={200}
57-
numRecordsPerPage={12}
58-
activePage={6}
50+
paginationRef={createPaginationRef({ page: 6, limit: 12 })}
5951
/>,
6052
)
6153

0 commit comments

Comments
 (0)