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'
1515 * A component to render a pagination.
1616 */
1717export default class Pagination extends Component {
18+ getInitialAutoControlledState ( ) {
19+ return { activePage : 1 }
20+ }
21+
1822 handleItemClick = ( e , { value : nextActivePage } ) => {
1923 const { activePage : prevActivePage } = this . state
2024
Original file line number Diff line number Diff line change @@ -78,4 +78,25 @@ describe('Pagination', () => {
7878 onPageChange . should . have . not . been . called ( )
7979 } )
8080 } )
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+ } )
81102} )
You can’t perform that action at this time.
0 commit comments