File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,10 @@ class Pagination extends React.Component {
170170 this . paginationNode = node ;
171171 } ;
172172
173- isValid = ( page ) => isInteger ( page ) && page !== this . state . current ;
173+ isValid = ( page ) => {
174+ const { total } = this . props ;
175+ return isInteger ( page ) && page !== this . state . current && isInteger ( total ) && total > 0 ;
176+ } ;
174177
175178 shouldDisplayQuickJumper = ( ) => {
176179 const { showQuickJumper, pageSize, total } = this . props ;
Original file line number Diff line number Diff line change @@ -3,6 +3,27 @@ import { mount } from 'enzyme';
33import Select from 'rc-select' ;
44import Pagination from '../src' ;
55
6+ describe ( 'Default Pagination' , ( ) => {
7+ let wrapper ;
8+ const onChange = jest . fn ( ) ;
9+
10+ beforeEach ( ( ) => {
11+ wrapper = mount ( < Pagination onChange = { onChange } /> ) ;
12+ } ) ;
13+
14+ afterEach ( ( ) => {
15+ wrapper . unmount ( ) ;
16+ onChange . mockReset ( ) ;
17+ } ) ;
18+
19+ it ( 'onChange should be forbidden when total is default' , ( ) => {
20+ const pagers = wrapper . find ( '.rc-pagination-item' ) ;
21+ const page1 = pagers . at ( 0 ) ;
22+ page1 . simulate ( 'click' ) ;
23+ expect ( onChange ) . toBeCalledTimes ( 0 ) ;
24+ } ) ;
25+ } ) ;
26+
627describe ( 'Uncontrolled Pagination' , ( ) => {
728 let wrapper ;
829 const onChange = jest . fn ( ) ;
You can’t perform that action at this time.
0 commit comments