Skip to content

Commit 6da4c43

Browse files
committed
Add unit test for the render function of spinners
1 parent 5d8e733 commit 6da4c43

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('vue-infinite-loading', () => {
3838
list: [],
3939
isDivScroll: false,
4040
direction: 'bottom',
41+
spinner: 'default',
4142
},
4243
template: `
4344
<div :style="{ overflow: isDivScroll ? 'auto' : 'visible' }">
@@ -48,6 +49,7 @@ describe('vue-infinite-loading', () => {
4849
:direction="direction"
4950
@infinite="infiniteHandler"
5051
ref="infiniteLoading"
52+
:spinner="spinner"
5153
>
5254
</infinite-loading>
5355
</div>
@@ -147,12 +149,13 @@ describe('vue-infinite-loading', () => {
147149
vm.$mount('#app');
148150
});
149151

150-
it('should not trigger load again before the last load is complete\n (use div as the container)', (done) => {
152+
it('should not trigger load again before the last load is complete\n (use div as the container and spiral spinner)', (done) => {
151153
vm = new Vue(Object.assign({}, basicConfig, {
152154
data: {
153155
list: [],
154156
isDivScroll: true,
155157
direction: 'bottom',
158+
spinner: 'spiral',
156159
},
157160
methods: {
158161
infiniteHandler: function infiniteHandler() {
@@ -177,14 +180,15 @@ describe('vue-infinite-loading', () => {
177180
vm.$mount('#app');
178181
});
179182

180-
it('should works again when reset it after a completion\n (use top direction)', (done) => {
183+
it('should works again when reset it after a completion\n (use top direction and bubbles spinner)', (done) => {
181184
let calledTimes = 0;
182185

183186
vm = new Vue(Object.assign({}, basicConfig, {
184187
data: {
185188
list: [],
186189
isDivScroll: false,
187190
direction: 'top',
191+
spinner: 'bubbles',
188192
},
189193
methods: {
190194
infiniteHandler: function infiniteHandler($state) {
@@ -201,7 +205,7 @@ describe('vue-infinite-loading', () => {
201205
});
202206
} else if (calledTimes === 2) {
203207
// check spinner
204-
expect(isShow(this.$el.querySelector('.loading-default'))).to.be.true;
208+
expect(isShow(this.$el.querySelector('.loading-bubbles'))).to.be.true;
205209
done();
206210
}
207211
},
@@ -211,14 +215,15 @@ describe('vue-infinite-loading', () => {
211215
vm.$mount('#app');
212216
});
213217

214-
it('should always load data until fill up the container\n (use div as the container)', (done) => {
218+
it('should always load data until fill up the container\n (use div as the container and circles spinner)', (done) => {
215219
let timer;
216220

217221
vm = new Vue(Object.assign({}, basicConfig, {
218222
data: {
219223
list: [],
220224
isDivScroll: true,
221225
direction: 'bottom',
226+
spinner: 'circles',
222227
},
223228
methods: {
224229
infiniteHandler: function infiniteHandler($state) {
@@ -270,6 +275,7 @@ describe('vue-infinite-loading', () => {
270275
list: [],
271276
isDivScroll: true,
272277
direction: 'top',
278+
spinner: 'default',
273279
};
274280
},
275281
methods: {
@@ -380,12 +386,13 @@ describe('vue-infinite-loading', () => {
380386
vm.$mount('#app');
381387
});
382388

383-
it('should debounce properly for the scroll event handler\n (use div as the container)', (done) => {
389+
it('should debounce properly for the scroll event handler\n (use div as the container and wave dots spinner)', (done) => {
384390
vm = new Vue(Object.assign({}, basicConfig, {
385391
data: {
386392
list: [...new Array(20).join('1').split('')],
387393
isDivScroll: true,
388394
direction: 'bottom',
395+
spinner: 'waveDots',
389396
},
390397
mounted: function mounted() {
391398
const scrollParent = this.$refs.infiniteLoading.scrollParent;

0 commit comments

Comments
 (0)