@@ -99,40 +99,40 @@ describe('PageButtons component', () => {
9999 expect ( secondButton ) . toHaveClass ( 'active' ) ;
100100 } ) ;
101101
102- describe ( 'Page button changes' , ( ) => {
103- const pages = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
104- const pageButtonProps = {
105- maxPage : 5 ,
106- tableName : 'test' ,
107- currentPage : 1 ,
108- pagesArray : pages ,
109- handleJump : ( ) => { } ,
110- } ;
111- const { maxPage, tableName } = pageButtonProps ;
102+ it ( 'correctly changes pages when clicking the next button' , ( ) => {
103+ pageButtonProps . currentPage = 1 ;
104+ const { getByRole } = render (
105+ < RecoilRoot >
106+ < PageButtons pageButtonProps = { pageButtonProps } />
107+ </ RecoilRoot >
108+ ) ;
109+ const nextButton = getByRole ( 'button' , { name : 'Next page' } ) ;
110+ fireEvent . click ( nextButton ) ;
111+ const secondButton = getByRole ( 'button' , { name : `${ tableName } -page2` } ) ;
112+ expect ( secondButton ) . toHaveClass ( 'active' ) ;
113+ } ) ;
112114
113- it ( 'correctly changes pages when clicking the next button' , ( ) => {
114- const { getByRole } = render (
115- < RecoilRoot >
116- < PageButtons pageButtonProps = { pageButtonProps } />
117- </ RecoilRoot >
118- ) ;
119- const nextButton = getByRole ( 'button' , { name : 'Next page' } ) ;
120- fireEvent . click ( nextButton ) ;
121- const secondButton = getByRole ( 'button' , { name : `${ tableName } -page2` } ) ;
122- expect ( secondButton ) . toHaveClass ( 'active' ) ;
123- } ) ;
115+ it ( 'correctly changes pages when clicking the previous button' , ( ) => {
116+ pageButtonProps . currentPage = 2 ;
117+ const { getByRole } = render (
118+ < RecoilRoot >
119+ < PageButtons pageButtonProps = { pageButtonProps } />
120+ </ RecoilRoot >
121+ ) ;
122+ const prevButton = getByRole ( 'button' , { name : 'Previous page' } ) ;
123+ fireEvent . click ( prevButton ) ;
124+ const firstButton = getByRole ( 'button' , { name : `${ tableName } -page1` } ) ;
125+ expect ( firstButton ) . toHaveClass ( 'active' ) ;
126+ } ) ;
124127
125- it ( 'correctly changes pages when clicking the previous button' , ( ) => {
126- pageButtonProps . currentPage = 2 ;
127- const { getByRole } = render (
128- < RecoilRoot >
129- < PageButtons pageButtonProps = { pageButtonProps } />
130- </ RecoilRoot >
131- ) ;
132- const prevButton = getByRole ( 'button' , { name : 'Previous page' } ) ;
133- fireEvent . click ( prevButton ) ;
134- const firstButton = getByRole ( 'button' , { name : `${ tableName } -page1` } ) ;
135- expect ( firstButton ) . toHaveClass ( 'active' ) ;
136- } ) ;
128+ it ( 'renders the correct page range and ellipsis (when range > 7)' , ( ) => {
129+ pageButtonProps . maxPage = 8 ;
130+ const { getByRole } = render (
131+ < RecoilRoot >
132+ < PageButtons pageButtonProps = { pageButtonProps } />
133+ </ RecoilRoot >
134+ ) ;
135+ const ellipsisButton = getByRole ( 'button' , { name : 'Page number overflow ellipsis' } ) ;
136+ expect ( ellipsisButton ) . toBeInTheDocument ( ) ;
137137 } ) ;
138138} ) ;
0 commit comments