File tree 4 files changed +46
-1
lines changed
4 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ export default {
115
115
this .selectPage ((this .currentPage + 1 ));
116
116
},
117
117
selectPage (page ) {
118
- if (page === ' ...' ) {
118
+ if (page === ' ...' || page === this . currentPage ) {
119
119
return ;
120
120
}
121
121
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ test('has correct DOM structure when on page 2', function () {
146
146
} ) ;
147
147
148
148
test ( 'emits correct event' , function ( ) {
149
+ exampleData . current_page = 1 ;
149
150
const wrapper = mount ( Bootstrap4Pagination , {
150
151
props : {
151
152
data : exampleData ,
@@ -159,6 +160,20 @@ test('emits correct event', function () {
159
160
expect ( event [ 0 ] ) . toEqual ( [ 2 ] ) ;
160
161
} ) ;
161
162
163
+ test ( 'does not emit event on current page' , function ( ) {
164
+ exampleData . current_page = 1 ;
165
+ const wrapper = mount ( Bootstrap4Pagination , {
166
+ props : {
167
+ data : exampleData ,
168
+ } ,
169
+ } ) ;
170
+
171
+ wrapper . findAll ( 'li' ) . at ( 1 ) . find ( 'a' ) . trigger ( 'click' ) ;
172
+
173
+ const event = wrapper . emitted ( 'pagination-change-page' ) ;
174
+ expect ( event ) . toBeUndefined ( ) ;
175
+ } ) ;
176
+
162
177
test ( 'has correct DOM structure when using slots' , function ( ) {
163
178
const wrapper = mount ( Bootstrap4Pagination , {
164
179
props : { data : exampleData } ,
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ test('has correct DOM structure when on page 2', function () {
146
146
} ) ;
147
147
148
148
test ( 'emits correct event' , function ( ) {
149
+ exampleData . current_page = 1 ;
149
150
const wrapper = mount ( Bootstrap5Pagination , {
150
151
props : {
151
152
data : exampleData ,
@@ -159,6 +160,20 @@ test('emits correct event', function () {
159
160
expect ( event [ 0 ] ) . toEqual ( [ 2 ] ) ;
160
161
} ) ;
161
162
163
+ test ( 'does not emit event on current page' , function ( ) {
164
+ exampleData . current_page = 1 ;
165
+ const wrapper = mount ( Bootstrap5Pagination , {
166
+ props : {
167
+ data : exampleData ,
168
+ } ,
169
+ } ) ;
170
+
171
+ wrapper . findAll ( 'li' ) . at ( 1 ) . find ( 'a' ) . trigger ( 'click' ) ;
172
+
173
+ const event = wrapper . emitted ( 'pagination-change-page' ) ;
174
+ expect ( event ) . toBeUndefined ( ) ;
175
+ } ) ;
176
+
162
177
test ( 'has correct DOM structure when using slots' , function ( ) {
163
178
const wrapper = mount ( Bootstrap5Pagination , {
164
179
props : { data : exampleData } ,
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ test('has correct DOM structure when on page 2', function () {
118
118
} ) ;
119
119
120
120
test ( 'emits correct event' , function ( ) {
121
+ exampleData . current_page = 1 ;
121
122
const wrapper = mount ( TailwindPagination , {
122
123
props : {
123
124
data : exampleData ,
@@ -131,6 +132,20 @@ test('emits correct event', function () {
131
132
expect ( event [ 0 ] ) . toEqual ( [ 2 ] ) ;
132
133
} ) ;
133
134
135
+ test ( 'does not emit event on current page' , function ( ) {
136
+ exampleData . current_page = 1 ;
137
+ const wrapper = mount ( TailwindPagination , {
138
+ props : {
139
+ data : exampleData ,
140
+ } ,
141
+ } ) ;
142
+
143
+ wrapper . findAll ( 'button' ) . at ( 1 ) . trigger ( 'click' ) ;
144
+
145
+ const event = wrapper . emitted ( 'pagination-change-page' ) ;
146
+ expect ( event ) . toBeUndefined ( ) ;
147
+ } ) ;
148
+
134
149
test ( 'has correct DOM structure when using slots' , function ( ) {
135
150
const wrapper = mount ( TailwindPagination , {
136
151
props : { data : exampleData } ,
You can’t perform that action at this time.
0 commit comments