File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ import PaginationItem from './PaginationItem'
15
15
* A component to render a pagination.
16
16
*/
17
17
export default class Pagination extends Component {
18
+ getInitialAutoControlledState ( ) {
19
+ return { activePage : 1 }
20
+ }
21
+
18
22
handleItemClick = ( e , { value : nextActivePage } ) => {
19
23
const { activePage : prevActivePage } = this . state
20
24
Original file line number Diff line number Diff line change @@ -78,4 +78,25 @@ describe('Pagination', () => {
78
78
onPageChange . should . have . not . been . called ( )
79
79
} )
80
80
} )
81
+
82
+ describe ( 'activePage' , ( ) => {
83
+ it ( 'defaults to "1"' , ( ) => {
84
+ const wrapper = mount ( < Pagination totalPages = { 3 } /> )
85
+
86
+ wrapper . find ( 'PaginationItem' ) . at ( 1 ) . prop ( 'value' ) . should . equal ( 1 )
87
+ wrapper . find ( 'PaginationItem' ) . at ( 5 ) . prop ( 'value' ) . should . equal ( 2 )
88
+ } )
89
+
90
+ it ( 'can be set via "defaultActivePage"' , ( ) => {
91
+ const wrapper = mount ( < Pagination defaultActivePage = { 2 } totalPages = { 3 } /> )
92
+
93
+ wrapper . find ( 'PaginationItem' ) . at ( 3 ) . should . have . prop ( 'active' )
94
+ } )
95
+
96
+ it ( 'can be set via "activePage"' , ( ) => {
97
+ const wrapper = mount ( < Pagination activePage = { 2 } totalPages = { 3 } /> )
98
+
99
+ wrapper . find ( 'PaginationItem' ) . at ( 3 ) . should . have . prop ( 'active' )
100
+ } )
101
+ } )
81
102
} )
You can’t perform that action at this time.
0 commit comments