@@ -6,9 +6,10 @@ import Pagination from '..';
6
6
/* eslint-disable no-undef */
7
7
describe ( 'Pagination accessibility tests' , ( ) => {
8
8
let wrappedComponent ;
9
+ let total = 10 ;
9
10
10
11
beforeEach ( ( ) => {
11
- wrappedComponent = mount ( < Pagination total = { 10 } /> ) ;
12
+ wrappedComponent = mount ( < Pagination total = { total } /> ) ;
12
13
} ) ;
13
14
14
15
afterEach ( ( ) => {
@@ -23,4 +24,24 @@ describe('Pagination accessibility tests', () => {
23
24
wrappedComponent . find ( '#next-button' ) . simulate ( 'click' ) ;
24
25
expect ( simulatedValue ( ) ) . to . equal ( expectedValueAfterChange ) ;
25
26
} ) ;
27
+
28
+ it ( 'Should not change the curentActive page when clicked on itself' , ( ) => {
29
+ const simulatedValue = ( ) => wrappedComponent . find ( 'div[data-react-active-page="active"]' ) . text ( ) ;
30
+ expect ( simulatedValue ( ) ) . equal ( '1' ) ;
31
+ wrappedComponent . find ( 'div[data-react-active-page="active"]' ) . simulate ( 'click' ) ;
32
+ expect ( simulatedValue ( ) ) . equal ( '1' ) ;
33
+ } ) ;
34
+
35
+ it ( 'Should navigate through pages correctly' , ( ) => {
36
+ const simulatedValue = ( ) => wrappedComponent . find ( 'div[data-react-active-page="active"]' ) . text ( ) ;
37
+ for ( let page = 1 ; page <= total ; page += 1 ) {
38
+ expect ( Number ( simulatedValue ( ) ) ) . equal ( page ) ;
39
+ wrappedComponent . find ( '#next-button' ) . simulate ( 'click' ) ;
40
+ }
41
+ wrappedComponent . setProps ( { defaultActive : total } ) ;
42
+ for ( let page = total ; page >= 1 ; page -= 1 ) {
43
+ expect ( Number ( simulatedValue ( ) ) ) . equal ( page ) ;
44
+ wrappedComponent . find ( '#prev-button' ) . simulate ( 'click' ) ;
45
+ }
46
+ } ) ;
26
47
} ) ;
0 commit comments