Skip to content

Commit 9bf3607

Browse files
committed
Add unit test for the feature of hide load result
1 parent 4565c80 commit 9bf3607

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,45 @@ describe('vue-infinite-loading', () => {
320320

321321
vm.$mount('#app');
322322
});
323+
324+
it('should support hide load result through blank slots', (done) => {
325+
let calledTimes = 0;
326+
327+
vm = new Vue(Object.assign({}, basicConfig, {
328+
methods: {
329+
infiniteHandler: function infiniteHandler() {
330+
if (calledTimes) {
331+
this.$refs.infiniteLoading.$emit('$InfiniteLoading:load');
332+
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
333+
this.$nextTick(() => {
334+
// check for no-more result display
335+
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[1])).to.be.false;
336+
done();
337+
});
338+
} else {
339+
calledTimes += 1;
340+
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
341+
this.$nextTick(() => {
342+
// check for no-result result display
343+
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[0])).to.be.false;
344+
345+
// reset component to check no-more status
346+
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
347+
});
348+
}
349+
},
350+
},
351+
template: `
352+
<infinite-loading
353+
@infinite="infiniteHandler"
354+
ref="infiniteLoading"
355+
>
356+
<span slot="no-results"></span>
357+
<span slot="no-more"></span>
358+
</infinite-loading>
359+
`,
360+
}));
361+
362+
vm.$mount('#app');
363+
});
323364
});

0 commit comments

Comments
 (0)