@@ -357,3 +357,134 @@ describe('hideOnSinglePage props', () => {
357357 ) ;
358358 } ) ;
359359} ) ;
360+
361+ describe ( 'custom showQuickJumper button Pagination' , ( ) => {
362+ let pagination = null ;
363+ const container = document . createElement ( 'div' ) ;
364+ document . body . appendChild ( container ) ;
365+
366+ let current = 1 ;
367+ let pageSize ;
368+ function onChange ( page , pSize ) {
369+ current = page ;
370+ pageSize = pSize ;
371+ }
372+
373+ beforeEach ( ( done ) => {
374+ ReactDOM . render (
375+ < Pagination
376+ onChange = { onChange }
377+ defaultCurrent = { 1 }
378+ total = { 25 }
379+ showQuickJumper = { { goButton : < button > go</ button > } }
380+ showTotal = { ( total , range ) => `${ range [ 0 ] } - ${ range [ 1 ] } of ${ total } items` }
381+ /> ,
382+ container ,
383+ function ( ) {
384+ pagination = this ;
385+ done ( ) ;
386+ } ,
387+ ) ;
388+ } ) ;
389+
390+ afterEach ( ( ) => {
391+ ReactDOM . unmountComponentAtNode ( container ) ;
392+ } ) ;
393+
394+ it ( 'should quick jump to expect page' , ( done ) => {
395+ const quickJumper = TestUtils . findRenderedDOMComponentWithClass (
396+ pagination ,
397+ 'rc-pagination-options-quick-jumper'
398+ ) ;
399+ const input = quickJumper . querySelector ( 'input' ) ;
400+ const goButton = quickJumper . querySelector ( 'button' ) ;
401+ expect ( TestUtils . isDOMComponent ( quickJumper ) ) . to . be ( true ) ;
402+ expect ( TestUtils . isDOMComponent ( input ) ) . to . be ( true ) ;
403+ expect ( TestUtils . isDOMComponent ( goButton ) ) . to . be ( true ) ;
404+ input . value = '2' ;
405+ Simulate . change ( input ) ;
406+ setTimeout ( ( ) => {
407+ Simulate . click ( goButton ) ;
408+ setTimeout ( ( ) => {
409+ expect ( pagination . state . current ) . to . be ( 2 ) ;
410+ expect ( current ) . to . be ( 2 ) ;
411+ expect ( pageSize ) . to . be ( 10 ) ;
412+ done ( ) ;
413+ } , 10 ) ;
414+ } , 10 ) ;
415+ } ) ;
416+ } ) ;
417+
418+
419+ describe ( 'simple Pagination' , ( ) => {
420+ let pagination = null ;
421+ const container = document . createElement ( 'div' ) ;
422+ document . body . appendChild ( container ) ;
423+
424+ let current = 1 ;
425+ let pageSize ;
426+ function onChange ( page , pSize ) {
427+ current = page ;
428+ pageSize = pSize ;
429+ }
430+
431+ beforeEach ( ( done ) => {
432+ ReactDOM . render (
433+ < Pagination
434+ simple
435+ onChange = { onChange }
436+ defaultCurrent = { 1 }
437+ total = { 25 }
438+ showQuickJumper = { { goButton : < button > go</ button > } }
439+ showTotal = { ( total , range ) => `${ range [ 0 ] } - ${ range [ 1 ] } of ${ total } items` }
440+ /> ,
441+ container ,
442+ function ( ) {
443+ pagination = this ;
444+ done ( ) ;
445+ } ,
446+ ) ;
447+ } ) ;
448+
449+ afterEach ( ( ) => {
450+ ReactDOM . unmountComponentAtNode ( container ) ;
451+ } ) ;
452+
453+ it ( 'default current page is 1' , ( ) => {
454+ const current3 = pagination . state . current ;
455+ expect ( current3 ) . to . be ( 1 ) ;
456+ } ) ;
457+
458+ it ( 'prev-button should be disabled' , ( ) => {
459+ const prevButton = TestUtils . findRenderedDOMComponentWithClass (
460+ pagination ,
461+ 'rc-pagination-prev'
462+ ) ;
463+ expect ( TestUtils . isDOMComponent ( prevButton ) ) . to . be ( true ) ;
464+ expect ( prevButton . className ) . to . contain ( 'rc-pagination-disabled' ) ;
465+ expect ( prevButton . getAttribute ( 'aria-disabled' ) ) . to . equal ( 'true' ) ;
466+ } ) ;
467+
468+ it ( 'should quick jump to expect page' , ( done ) => {
469+ const quickJumper = TestUtils . findRenderedDOMComponentWithClass (
470+ pagination ,
471+ 'rc-pagination-simple'
472+ ) ;
473+ const input = quickJumper . querySelector ( 'input' ) ;
474+ const goButton = quickJumper . querySelector ( 'button' ) ;
475+ expect ( TestUtils . isDOMComponent ( quickJumper ) ) . to . be ( true ) ;
476+ expect ( TestUtils . isDOMComponent ( input ) ) . to . be ( true ) ;
477+ expect ( TestUtils . isDOMComponent ( goButton ) ) . to . be ( true ) ;
478+ input . value = '2' ;
479+ Simulate . change ( input ) ;
480+ setTimeout ( ( ) => {
481+ Simulate . click ( goButton ) ;
482+ setTimeout ( ( ) => {
483+ expect ( pagination . state . current ) . to . be ( 2 ) ;
484+ expect ( current ) . to . be ( 2 ) ;
485+ expect ( pageSize ) . to . be ( 10 ) ;
486+ done ( ) ;
487+ } , 10 ) ;
488+ } , 10 ) ;
489+ } ) ;
490+ } ) ;
0 commit comments