@@ -19,31 +19,25 @@ describe('InfiniteLoading.vue', () => {
19
19
isLoadedAll : false ,
20
20
isDivScroll : true ,
21
21
isCustomSpinner : false ,
22
- listContainerHeight : 100 ,
23
- listItemHeight : 10 ,
24
- customSpinnerHeight : 10 ,
22
+ listContainerHeight : 200 ,
23
+ listItemHeight : 20 ,
25
24
} ,
26
25
template : `
27
26
<div style="margin: 0; padding: 0;"
28
27
:style="{
29
28
overflow: isDivScroll ? 'auto' : 'visible',
30
29
height: listContainerHeight + 'px'
31
30
}">
32
- <ul style="margin: 0; padding: 0; font-size: 5px; ">
31
+ <ul style="margin: 0; padding: 0;">
33
32
<li v-for="item in list" v-text="item"
34
- style="height: 10px; margin: 0; padding: 0;"
35
- :style="{
36
- height: listItemHeight + 'px'
33
+ :style="{ height: listItemHeight + 'px' }"
37
34
}"></li>
38
35
</ul>
39
36
<infinite-loading :distance="distance"
40
37
:on-infinite="onInfinite"
41
38
v-if="!isLoadedAll">
42
39
<span slot="spinner" v-if="isCustomSpinner">
43
- <i class="custom-spinner" style="display: inline-block; width: 10px;"
44
- :style="{
45
- height: customSpinnerHeight + 'px'
46
- }"></i>
40
+ <i class="custom-spinner"></i>
47
41
</span>
48
42
</infinite-loading>
49
43
</div>
@@ -145,32 +139,24 @@ describe('InfiniteLoading.vue', () => {
145
139
vm . $mount ( ) . $appendTo ( 'body' ) ;
146
140
} ) ;
147
141
148
- it ( 'should load results to fill up the container' , function fillUpTest ( done ) {
149
- const TEST_TIMEOUT = 2000 ;
150
- const mocha = this ;
151
- let i = 0 ;
152
- vm . listContainerHeight = 100 ;
153
- vm . listItemHeight = 10 ;
154
- vm . distance = 10 ;
155
- vm . isCustomSpinner = true ;
156
- vm . customSpinnerHeight = 10 ;
142
+ it ( 'should load results to fill up the container' , ( done ) => {
157
143
const expectedCount = Math . floor ( vm . listContainerHeight / vm . listItemHeight ) ;
144
+ let i = 0 ;
145
+ let timer ;
158
146
159
147
vm . onInfinite = function test ( ) {
160
- this . list . push ( ++ i ) ;
161
- Vue . nextTick ( ( ) => {
148
+ setTimeout ( ( ) => {
149
+ this . list . push ( ++ i ) ;
162
150
this . $broadcast ( '$InfiniteLoading:loaded' ) ;
163
- if ( i === expectedCount ) {
164
- mocha . timeout ( TEST_TIMEOUT + 100 ) ;
165
- setTimeout ( ( ) => {
166
- if ( i === expectedCount ) {
167
- done ( ) ;
168
- } else {
169
- done ( new Error ( 'Unexpected number of items added' ) ) ;
170
- }
171
- } , TEST_TIMEOUT ) ;
172
- }
173
- } ) ;
151
+ clearTimeout ( timer ) ;
152
+ timer = setTimeout ( ( ) => {
153
+ if ( i >= expectedCount ) {
154
+ done ( ) ;
155
+ } else {
156
+ done ( new Error ( 'List not be fill up!' ) ) ;
157
+ }
158
+ } , 100 ) ;
159
+ } , 1 ) ;
174
160
} . bind ( vm ) ;
175
161
176
162
vm . $mount ( ) . $appendTo ( 'body' ) ;
0 commit comments