1
1
/*global describe, beforeEach, module, it, expect, runTest */
2
- describe ( 'uiScroll Paddings cache ' , ( ) => {
2
+ describe ( 'uiScroll Paddings spec. ' , ( ) => {
3
3
'use strict' ;
4
4
5
+ let datasource ;
5
6
beforeEach ( module ( 'ui.scroll' ) ) ;
6
7
beforeEach ( module ( 'ui.scroll.test.datasources' ) ) ;
8
+ beforeEach (
9
+ inject ( function ( myResponsiveDatasource ) {
10
+ datasource = myResponsiveDatasource ;
11
+ } )
12
+ ) ;
7
13
8
14
const itemsCount = 30 ;
9
15
const itemHeight = 100 ;
@@ -60,9 +66,9 @@ describe('uiScroll Paddings cache', () => {
60
66
61
67
function insertItems ( datasource , index , items = [ ] ) {
62
68
if ( index >= datasource . min && index <= datasource . max && items . length ) {
63
- const index = datasource . data . indexOf ( datasource . data [ index - datasource . min ] ) ;
64
- if ( index > - 1 ) {
65
- datasource . data . splice ( index , 0 , items ) ;
69
+ const indexToInsert = datasource . data . indexOf ( datasource . data [ index - datasource . min ] ) ;
70
+ if ( indexToInsert > - 1 ) {
71
+ datasource . data . splice ( indexToInsert , 0 , items ) ;
66
72
datasource . max += items . length ;
67
73
}
68
74
}
@@ -77,11 +83,7 @@ describe('uiScroll Paddings cache', () => {
77
83
expect ( rowElement . innerHTML ) . toBe ( content ) ;
78
84
}
79
85
80
- it ( 'should set up properly' , ( ) => {
81
- let datasource ;
82
- inject ( function ( myResponsiveDatasource ) {
83
- datasource = myResponsiveDatasource ;
84
- } ) ;
86
+ it ( '\nshould set up properly' , ( ) => {
85
87
runTest ( scrollSettings ,
86
88
( ) => {
87
89
expect ( datasource . min ) . toBe ( 1 ) ;
@@ -90,13 +92,9 @@ describe('uiScroll Paddings cache', () => {
90
92
) ;
91
93
} ) ;
92
94
93
- describe ( 'removing outside the buffer via indexed-based applyUpdates\n' , ( ) => {
95
+ describe ( 'Removing outside the buffer via indexed-based applyUpdates\n' , ( ) => {
94
96
95
97
it ( 'should delete last row' , ( ) => {
96
- let datasource ;
97
- inject ( function ( myResponsiveDatasource ) {
98
- datasource = myResponsiveDatasource ;
99
- } ) ;
100
98
runTest ( scrollSettings ,
101
99
( viewport , scope ) => {
102
100
@@ -116,10 +114,6 @@ describe('uiScroll Paddings cache', () => {
116
114
} ) ;
117
115
118
116
it ( 'should delete last row and then the next after last' , ( ) => {
119
- let datasource ;
120
- inject ( function ( myResponsiveDatasource ) {
121
- datasource = myResponsiveDatasource ;
122
- } ) ;
123
117
runTest ( scrollSettings ,
124
118
( viewport , scope ) => {
125
119
@@ -140,18 +134,14 @@ describe('uiScroll Paddings cache', () => {
140
134
) ;
141
135
} ) ;
142
136
143
- it ( 'should delete pre-last row' , function ( ) {
144
- var datasource ;
145
- inject ( function ( myResponsiveDatasource ) {
146
- datasource = myResponsiveDatasource ;
147
- } ) ;
137
+ it ( 'should delete pre-last row' , ( ) => {
148
138
runTest ( scrollSettings ,
149
- function ( viewport , scope ) {
139
+ ( viewport , scope ) => {
150
140
151
141
scrollBottom ( viewport , MAX ) ;
152
142
scrollTop ( viewport ) ;
153
143
154
- var initialBottomHeight = getBottomPaddingHeight ( viewport ) ;
144
+ const initialBottomHeight = getBottomPaddingHeight ( viewport ) ;
155
145
removeItem ( datasource , datasource . max - 1 ) ;
156
146
scope . adapter . applyUpdates ( itemsCount - 1 , [ ] ) ;
157
147
expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( initialBottomHeight - itemHeight ) ;
@@ -165,10 +155,6 @@ describe('uiScroll Paddings cache', () => {
165
155
} ) ;
166
156
167
157
it ( 'should delete first row' , ( ) => {
168
- let datasource ;
169
- inject ( function ( myResponsiveDatasource ) {
170
- datasource = myResponsiveDatasource ;
171
- } ) ;
172
158
runTest ( scrollSettings ,
173
159
( viewport , scope ) => {
174
160
@@ -187,10 +173,6 @@ describe('uiScroll Paddings cache', () => {
187
173
} ) ;
188
174
189
175
it ( 'should delete first row and then the next after first' , ( ) => {
190
- let datasource ;
191
- inject ( function ( myResponsiveDatasource ) {
192
- datasource = myResponsiveDatasource ;
193
- } ) ;
194
176
runTest ( scrollSettings ,
195
177
( viewport , scope ) => {
196
178
@@ -210,17 +192,13 @@ describe('uiScroll Paddings cache', () => {
210
192
) ;
211
193
} ) ;
212
194
213
- it ( 'should delete second' , function ( ) {
214
- var datasource ;
215
- inject ( function ( myResponsiveDatasource ) {
216
- datasource = myResponsiveDatasource ;
217
- } ) ;
195
+ it ( 'should delete second' , ( ) => {
218
196
runTest ( scrollSettings ,
219
- function ( viewport , scope ) {
197
+ ( viewport , scope ) => {
220
198
221
199
scrollBottom ( viewport , MAX ) ;
222
200
223
- var initialTopHeight = getTopPaddingHeight ( viewport ) ;
201
+ const initialTopHeight = getTopPaddingHeight ( viewport ) ;
224
202
removeItem ( datasource , datasource . min + 1 ) ;
225
203
scope . adapter . applyUpdates ( 2 , [ ] ) ;
226
204
expect ( getTopPaddingHeight ( viewport ) ) . toBe ( initialTopHeight - itemHeight * 1 ) ;
@@ -232,16 +210,11 @@ describe('uiScroll Paddings cache', () => {
232
210
}
233
211
) ;
234
212
} ) ;
235
-
236
213
} ) ;
237
214
238
- describe ( 'removing inside the buffer\n' , ( ) => {
215
+ describe ( 'Removing inside the buffer\n' , ( ) => {
239
216
240
217
it ( 'should delete second row via index-based applyUpdates' , ( ) => {
241
- let datasource ;
242
- inject ( function ( myResponsiveDatasource ) {
243
- datasource = myResponsiveDatasource ;
244
- } ) ;
245
218
runTest ( scrollSettings ,
246
219
( viewport , scope ) => {
247
220
@@ -262,10 +235,6 @@ describe('uiScroll Paddings cache', () => {
262
235
} ) ;
263
236
264
237
it ( 'should delete second row via function-based applyUpdates' , ( ) => {
265
- let datasource ;
266
- inject ( function ( myResponsiveDatasource ) {
267
- datasource = myResponsiveDatasource ;
268
- } ) ;
269
238
runTest ( scrollSettings ,
270
239
( viewport , scope ) => {
271
240
@@ -284,7 +253,6 @@ describe('uiScroll Paddings cache', () => {
284
253
}
285
254
) ;
286
255
} ) ;
287
-
288
256
} ) ;
289
257
290
258
} ) ;
0 commit comments