Skip to content

Commit 22af677

Browse files
committed
Add unit test for the top direction load function
1 parent bf23c43 commit 22af677

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('InfiniteLoading.vue', () => {
2121
isCustomSpinner: false,
2222
listContainerHeight: 200,
2323
listItemHeight: 20,
24+
direction: 'bottom',
2425
},
2526
template: `
2627
<div style="margin: 0; padding: 0;"
@@ -34,6 +35,7 @@ describe('InfiniteLoading.vue', () => {
3435
}"></li>
3536
</ul>
3637
<infinite-loading :distance="distance"
38+
:direction="direction"
3739
:on-infinite="onInfinite"
3840
v-if="!isLoadedAll">
3941
<span slot="spinner" v-if="isCustomSpinner">
@@ -184,4 +186,16 @@ describe('InfiniteLoading.vue', () => {
184186

185187
expect(vm.$el.querySelector('.custom-spinner')).to.be.ok;
186188
});
189+
190+
it('should load data when scroll top (direction attribute)', (done) => {
191+
vm.direction = 'top';
192+
vm.onInfinite = function test() {
193+
Vue.nextTick(() => {
194+
expect(isShow(vm.$el.querySelector('.loading-default'))).to.be.true;
195+
done();
196+
});
197+
};
198+
199+
vm.$mount().$appendTo('body');
200+
});
187201
});

0 commit comments

Comments
 (0)