File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -213,4 +213,50 @@ describe('InfiniteLoading.vue', () => {
213213
214214 vm . $mount ( '#app' ) ;
215215 } ) ;
216+
217+ it ( 'should load data once when deactivated by keep-alive feature' , ( done ) => {
218+ let callCount = 0 ;
219+ let app ;
220+
221+ const InfiniteComponent = {
222+ data : initConf . data ,
223+ template : initConf . template ,
224+ components : initConf . components ,
225+ methods : {
226+ onInfinite ( ) {
227+ callCount ++ ;
228+ if ( callCount === 1 ) {
229+ this . $parent . currentView = null ;
230+ Vue . nextTick ( ( ) => {
231+ this . $refs . infiniteLoading . $emit ( '$InfiniteLoading:loaded' ) ;
232+ setTimeout ( ( ) => {
233+ expect ( callCount ) . to . equal ( 1 ) ;
234+ app . $destroy ( true ) ;
235+ app . $el && app . $el . remove ( ) ;
236+ done ( ) ;
237+ } , 1000 ) ;
238+ } ) ;
239+ }
240+ } ,
241+ } ,
242+ } ;
243+
244+ app = new Vue ( {
245+ data ( ) {
246+ return {
247+ currentView : 'InfiniteComponent' ,
248+ } ;
249+ } ,
250+ template : `
251+ <keep-alive>
252+ <component :is="currentView"></component>
253+ </keep-alive>
254+ ` ,
255+ components : {
256+ InfiniteComponent,
257+ } ,
258+ } ) ;
259+
260+ app . $mount ( '#app' ) ;
261+ } ) ;
216262} ) ;
You can’t perform that action at this time.
0 commit comments