1+ /* eslint-disable no-console */
2+
13import Vue from 'vue/dist/vue.common' ;
24import InfiniteLoading from '../../../src/components/InfiniteLoading' ;
35
@@ -27,15 +29,15 @@ describe('vue-infinite-loading', () => {
2729 </ul>
2830 <infinite-loading
2931 :direction="direction"
30- :on- infinite="onInfinite "
32+ @ infinite="infiniteHandler "
3133 ref="infiniteLoading"
3234 >
3335 </infinite-loading>
3436 </div>
3537 ` ,
3638 components : { InfiniteLoading } ,
3739 methods : {
38- onInfinite ( ) { } ,
40+ infiniteHandler ( ) { } ,
3941 } ,
4042 } ;
4143
@@ -93,7 +95,7 @@ describe('vue-infinite-loading', () => {
9395 it ( 'should complete a standard life circle\n (init -> loading -> loaded -> complete)' , ( done ) => {
9496 vm = new Vue ( Object . assign ( { } , basicConfig , {
9597 methods : {
96- onInfinite : function onInfinite ( ) {
98+ infiniteHandler : function infiniteHandler ( ) {
9799 for ( let i = 0 , j = this . list . length ; i < 3 ; i += 1 ) {
98100 this . list . push ( j + i ) ;
99101 }
@@ -135,7 +137,7 @@ describe('vue-infinite-loading', () => {
135137 direction : 'bottom' ,
136138 } ,
137139 methods : {
138- onInfinite : function onInfinite ( ) {
140+ infiniteHandler : function infiniteHandler ( ) {
139141 const scrollParent = this . $refs . infiniteLoading . scrollParent ;
140142 const loadCountEachTime = 10 ;
141143
@@ -167,7 +169,7 @@ describe('vue-infinite-loading', () => {
167169 direction : 'top' ,
168170 } ,
169171 methods : {
170- onInfinite : function onInfinite ( ) {
172+ infiniteHandler : function infiniteHandler ( ) {
171173 calledTimes += 1 ;
172174
173175 if ( calledTimes === 1 ) {
@@ -201,7 +203,7 @@ describe('vue-infinite-loading', () => {
201203 direction : 'bottom' ,
202204 } ,
203205 methods : {
204- onInfinite : function onInfinite ( ) {
206+ infiniteHandler : function infiniteHandler ( ) {
205207 this . list . push ( this . list . length + 1 ) ;
206208 this . $nextTick ( ( ) => {
207209 this . $refs . infiniteLoading . $emit ( '$InfiniteLoading:loaded' ) ;
@@ -232,7 +234,7 @@ describe('vue-infinite-loading', () => {
232234 app . setAttribute ( 'infinite-wrapper' , '' ) ; // add `infinite-wrapper` attribute for app container
233235 vm = new Vue ( Object . assign ( { } , basicConfig , {
234236 methods : {
235- onInfinite : function onInfinite ( ) {
237+ infiniteHandler : function infiniteHandler ( ) {
236238 expect ( this . $refs . infiniteLoading . scrollParent ) . to . equal ( app ) ;
237239 done ( ) ;
238240 } ,
@@ -253,7 +255,7 @@ describe('vue-infinite-loading', () => {
253255 } ;
254256 } ,
255257 methods : {
256- onInfinite : function onInfinite ( ) {
258+ infiniteHandler : function infiniteHandler ( ) {
257259 calledTimes += 1 ;
258260
259261 if ( calledTimes === 1 ) {
@@ -289,4 +291,33 @@ describe('vue-infinite-loading', () => {
289291
290292 vm . $mount ( '#app' ) ;
291293 } ) ;
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+ } ) ;
292323} ) ;
0 commit comments