@@ -2,6 +2,9 @@ import React from 'react';
22import  {  mount  }  from  'enzyme' ; 
33import  Pagination  from  '../src' ; 
44
5+ const  sleep  =  ( timeout  =  0 )  => 
6+   new  Promise ( resolve  =>  setTimeout ( resolve ,  timeout ) ) ; 
7+ 
58describe ( 'Uncontrolled Pagination' ,  ( )  =>  { 
69  let  wrapper ; 
710  const  onChange  =  jest . fn ( ) ; 
@@ -77,4 +80,64 @@ describe('Uncontrolled Pagination', () => {
7780    expect ( onChange ) . toHaveBeenLastCalledWith ( 2 ,  10 ) ; 
7881    shouldHighlightRight ( ) ; 
7982  } ) ; 
83+ 
84+   it ( 'should response next page' ,  ( )  =>  { 
85+     const  nextButton  =  wrapper . find ( '.rc-pagination-next' ) ; 
86+     nextButton . simulate ( 'click' ) ; 
87+     expect ( wrapper . state ( ) . current ) . toBe ( 2 ) ; 
88+     expect ( onChange ) . toHaveBeenLastCalledWith ( 2 ,  10 ) ; 
89+     shouldHighlightRight ( ) ; 
90+   } ) ; 
91+ 
92+   it ( 'should quick jump to expect page' ,  ( )  =>  { 
93+     const  quickJumper  =  wrapper . find ( '.rc-pagination-options-quick-jumper' ) ; 
94+     const  input  =  quickJumper . find ( 'input' ) ; 
95+     const  goButton  =  quickJumper . find ( 'button' ) ; 
96+     input . simulate ( 'change' ,  {  target : {  value : '2'  }  } ) ; 
97+     goButton . simulate ( 'click' ) ; 
98+     expect ( wrapper . state ( ) . current ) . toBe ( 2 ) ; 
99+     expect ( onChange ) . toHaveBeenLastCalledWith ( 2 ,  10 ) ; 
100+   } ) ; 
101+ 
102+   // https://github.com/ant-design/ant-design/issues/17763 
103+   it ( 'should not jump when blur input when there is goButton' ,  ( )  =>  { 
104+     const  quickJumper  =  wrapper . find ( '.rc-pagination-options-quick-jumper' ) ; 
105+     const  input  =  quickJumper . find ( 'input' ) ; 
106+     input . simulate ( 'focus' ) ; 
107+     input . simulate ( 'change' ,  {  target : {  value : '2'  }  } ) ; 
108+     input . simulate ( 'blur' ) ; 
109+     expect ( wrapper . state ( ) . current ) . toBe ( 1 ) ; 
110+     expect ( onChange ) . not . toBeCalled ( ) ; 
111+   } ) ; 
112+ 
113+   // https://github.com/ant-design/ant-design/issues/17763 
114+   it ( 'should not jump when blur input when there is not goButton' ,  ( )  =>  { 
115+     const  component  =  mount ( 
116+       < Pagination  pageSize = { 10 }  total = { 20 }  showQuickJumper  /> , 
117+     ) ; 
118+     const  quickJumper  =  component . find ( '.rc-pagination-options-quick-jumper' ) ; 
119+     const  input  =  quickJumper . find ( 'input' ) ; 
120+     input . simulate ( 'change' ,  {  target : {  value : '2'  }  } ) ; 
121+     input . simulate ( 'blur' ) ; 
122+     expect ( component . state ( ) . current ) . toBe ( 2 ) ; 
123+   } ) ; 
124+ 
125+   // https://github.com/ant-design/ant-design/issues/15539 
126+   it ( 'should hide quick jumper when only one page' ,  ( )  =>  { 
127+     const  component  =  mount ( 
128+       < Pagination  pageSize = { 10 }  total = { 10 }  showQuickJumper  /> , 
129+     ) ; 
130+     const  quickJumper  =  component . find ( '.rc-pagination-options-quick-jumper' ) ; 
131+     expect ( quickJumper . length ) . toBe ( 0 ) ; 
132+   } ) ; 
133+ 
134+   it ( 'should display total items' ,  ( )  =>  { 
135+     const  totalText  =  wrapper . find ( '.rc-pagination-total-text' ) ; 
136+     expect ( totalText . text ( ) ) . toBe ( '1 - 10 of 25 items' ) ; 
137+     const  nextButton  =  wrapper . find ( '.rc-pagination-next' ) ; 
138+     nextButton . simulate ( 'click' ) ; 
139+     expect ( totalText . text ( ) ) . toBe ( '11 - 20 of 25 items' ) ; 
140+     nextButton . simulate ( 'click' ) ; 
141+     expect ( totalText . text ( ) ) . toBe ( '21 - 25 of 25 items' ) ; 
142+   } ) ; 
80143} ) ; 
0 commit comments