1
+ /* eslint-disable no-console */
2
+
1
3
import Vue from 'vue/dist/vue.common' ;
2
4
import InfiniteLoading from '../../../src/components/InfiniteLoading' ;
3
5
@@ -27,15 +29,15 @@ describe('vue-infinite-loading', () => {
27
29
</ul>
28
30
<infinite-loading
29
31
:direction="direction"
30
- :on- infinite="onInfinite "
32
+ @ infinite="infiniteHandler "
31
33
ref="infiniteLoading"
32
34
>
33
35
</infinite-loading>
34
36
</div>
35
37
` ,
36
38
components : { InfiniteLoading } ,
37
39
methods : {
38
- onInfinite ( ) { } ,
40
+ infiniteHandler ( ) { } ,
39
41
} ,
40
42
} ;
41
43
@@ -93,7 +95,7 @@ describe('vue-infinite-loading', () => {
93
95
it ( 'should complete a standard life circle\n (init -> loading -> loaded -> complete)' , ( done ) => {
94
96
vm = new Vue ( Object . assign ( { } , basicConfig , {
95
97
methods : {
96
- onInfinite : function onInfinite ( ) {
98
+ infiniteHandler : function infiniteHandler ( ) {
97
99
for ( let i = 0 , j = this . list . length ; i < 3 ; i += 1 ) {
98
100
this . list . push ( j + i ) ;
99
101
}
@@ -135,7 +137,7 @@ describe('vue-infinite-loading', () => {
135
137
direction : 'bottom' ,
136
138
} ,
137
139
methods : {
138
- onInfinite : function onInfinite ( ) {
140
+ infiniteHandler : function infiniteHandler ( ) {
139
141
const scrollParent = this . $refs . infiniteLoading . scrollParent ;
140
142
const loadCountEachTime = 10 ;
141
143
@@ -167,7 +169,7 @@ describe('vue-infinite-loading', () => {
167
169
direction : 'top' ,
168
170
} ,
169
171
methods : {
170
- onInfinite : function onInfinite ( ) {
172
+ infiniteHandler : function infiniteHandler ( ) {
171
173
calledTimes += 1 ;
172
174
173
175
if ( calledTimes === 1 ) {
@@ -201,7 +203,7 @@ describe('vue-infinite-loading', () => {
201
203
direction : 'bottom' ,
202
204
} ,
203
205
methods : {
204
- onInfinite : function onInfinite ( ) {
206
+ infiniteHandler : function infiniteHandler ( ) {
205
207
this . list . push ( this . list . length + 1 ) ;
206
208
this . $nextTick ( ( ) => {
207
209
this . $refs . infiniteLoading . $emit ( '$InfiniteLoading:loaded' ) ;
@@ -232,7 +234,7 @@ describe('vue-infinite-loading', () => {
232
234
app . setAttribute ( 'infinite-wrapper' , '' ) ; // add `infinite-wrapper` attribute for app container
233
235
vm = new Vue ( Object . assign ( { } , basicConfig , {
234
236
methods : {
235
- onInfinite : function onInfinite ( ) {
237
+ infiniteHandler : function infiniteHandler ( ) {
236
238
expect ( this . $refs . infiniteLoading . scrollParent ) . to . equal ( app ) ;
237
239
done ( ) ;
238
240
} ,
@@ -253,7 +255,7 @@ describe('vue-infinite-loading', () => {
253
255
} ;
254
256
} ,
255
257
methods : {
256
- onInfinite : function onInfinite ( ) {
258
+ infiniteHandler : function infiniteHandler ( ) {
257
259
calledTimes += 1 ;
258
260
259
261
if ( calledTimes === 1 ) {
@@ -289,4 +291,33 @@ describe('vue-infinite-loading', () => {
289
291
290
292
vm . $mount ( '#app' ) ;
291
293
} ) ;
294
+
295
+ it ( 'should still works properly with the deprecated property `:on-infinite` but through warning' , ( done ) => {
296
+ const originalError = console . warn ;
297
+ let isThroughWarn ;
298
+
299
+ console . warn = ( text ) => {
300
+ if ( text . indexOf ( '@infinite' ) > - 1 ) {
301
+ isThroughWarn = true ;
302
+ }
303
+ } ;
304
+
305
+ vm = new Vue ( Object . assign ( { } , basicConfig , {
306
+ methods : {
307
+ onInfinite : function onInfinite ( ) {
308
+ expect ( isThroughWarn ) . to . be . true ;
309
+ console . warn = originalError ;
310
+ done ( ) ;
311
+ } ,
312
+ } ,
313
+ template : `
314
+ <infinite-loading
315
+ :on-infinite="onInfinite"
316
+ >
317
+ </infinite-loading>
318
+ ` ,
319
+ } ) ) ;
320
+
321
+ vm . $mount ( '#app' ) ;
322
+ } ) ;
292
323
} ) ;
0 commit comments