@@ -3,29 +3,28 @@ import { render } from "../../testHelpers/renderHelpers"
3
3
import { PaginationWidget } from "./PaginationWidget"
4
4
5
5
describe ( "PaginatedList" , ( ) => {
6
- it ( "displays an accessible previous and next button regardless of the number of pages" , async ( ) => {
7
- const { container } = render (
6
+ it ( "displays an accessible previous and next button" , ( ) => {
7
+ render (
8
8
< PaginationWidget
9
9
prevLabel = "Previous"
10
10
nextLabel = "Next"
11
+ numRecords = { 200 }
12
+ numRecordsPerPage = { 12 }
13
+ activePage = { 1 }
11
14
onPrevClick = { ( ) => jest . fn ( ) }
12
15
onNextClick = { ( ) => jest . fn ( ) }
13
16
/> ,
14
17
)
15
18
16
19
expect (
17
- await screen . findByRole ( "button" , { name : "Previous page" } ) ,
18
- ) . toBeTruthy ( )
19
- expect (
20
- await screen . findByRole ( "button" , { name : "Next page" } ) ,
21
- ) . toBeTruthy ( )
22
- // Shouldn't render any pages if no records are passed in
20
+ screen . getByRole ( "button" , { name : "Previous page" } ) ,
21
+ ) . toBeInTheDocument ( )
23
22
expect (
24
- await container . querySelectorAll ( ` button[ name="Page button"]` ) ,
25
- ) . toHaveLength ( 0 )
23
+ screen . getByRole ( " button" , { name : "Next page" } ) ,
24
+ ) . toBeInTheDocument ( )
26
25
} )
27
26
28
- it ( "displays the expected number of pages with one ellipsis tile" , async ( ) => {
27
+ it ( "displays the expected number of pages with one ellipsis tile" , ( ) => {
29
28
const { container } = render (
30
29
< PaginationWidget
31
30
prevLabel = "Previous"
@@ -41,11 +40,11 @@ describe("PaginatedList", () => {
41
40
42
41
// 7 total spaces. 6 are page numbers, one is ellipsis
43
42
expect (
44
- await container . querySelectorAll ( `button[name="Page button"]` ) ,
43
+ container . querySelectorAll ( `button[name="Page button"]` ) ,
45
44
) . toHaveLength ( 6 )
46
45
} )
47
46
48
- it ( "displays the expected number of pages with two ellipsis tiles" , async ( ) => {
47
+ it ( "displays the expected number of pages with two ellipsis tiles" , ( ) => {
49
48
const { container } = render (
50
49
< PaginationWidget
51
50
prevLabel = "Previous"
@@ -61,7 +60,7 @@ describe("PaginatedList", () => {
61
60
62
61
// 7 total spaces. 2 sets of ellipsis on either side of the active page
63
62
expect (
64
- await container . querySelectorAll ( `button[name="Page button"]` ) ,
63
+ container . querySelectorAll ( `button[name="Page button"]` ) ,
65
64
) . toHaveLength ( 5 )
66
65
} )
67
66
} )
0 commit comments