@@ -68,10 +68,10 @@ describe('uiScroll Paddings cache', () => {
68
68
}
69
69
}
70
70
71
- function checkRow ( viewport , row , content ) {
72
- const children = viewport . children ( ) ;
73
- if ( row < 0 ) { // from the end
74
- row = children . length - 2 + row ;
71
+ function checkRow ( viewport , row , content , tail = false ) {
72
+ var children = viewport . children ( ) ;
73
+ if ( tail ) {
74
+ row = children . length - 1 - row ;
75
75
}
76
76
const rowElement = children [ row ] ;
77
77
expect ( rowElement . innerHTML ) . toBe ( content ) ;
@@ -110,7 +110,7 @@ describe('uiScroll Paddings cache', () => {
110
110
111
111
scrollBottom ( viewport , MAX ) ;
112
112
expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
113
- checkRow ( viewport , - 1 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) ) ;
113
+ checkRow ( viewport , 1 , ( itemsCount - 1 ) + ': item' + ( itemsCount - 1 ) , true ) ;
114
114
}
115
115
) ;
116
116
} ) ;
@@ -135,7 +135,31 @@ describe('uiScroll Paddings cache', () => {
135
135
136
136
scrollBottom ( viewport , MAX ) ;
137
137
expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight * 2 ) ;
138
- checkRow ( viewport , - 1 , ( itemsCount - 3 ) + ': item' + ( itemsCount - 3 ) ) ;
138
+ checkRow ( viewport , 1 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) , true ) ;
139
+ }
140
+ ) ;
141
+ } ) ;
142
+
143
+ it ( 'should delete pre-last row' , function ( ) {
144
+ var datasource ;
145
+ inject ( function ( myResponsiveDatasource ) {
146
+ datasource = myResponsiveDatasource ;
147
+ } ) ;
148
+ runTest ( scrollSettings ,
149
+ function ( viewport , scope ) {
150
+
151
+ scrollBottom ( viewport , MAX ) ;
152
+ scrollTop ( viewport ) ;
153
+
154
+ var initialBottomHeight = getBottomPaddingHeight ( viewport ) ;
155
+ removeItem ( datasource , datasource . max - 1 ) ;
156
+ scope . adapter . applyUpdates ( itemsCount - 1 , [ ] ) ;
157
+ expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( initialBottomHeight - itemHeight ) ;
158
+
159
+ scrollBottom ( viewport , MAX ) ;
160
+ expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
161
+ checkRow ( viewport , 1 , ( itemsCount - 1 ) + ': item' + itemsCount , true ) ;
162
+ checkRow ( viewport , 2 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) , true ) ;
139
163
}
140
164
) ;
141
165
} ) ;
@@ -186,6 +210,29 @@ describe('uiScroll Paddings cache', () => {
186
210
) ;
187
211
} ) ;
188
212
213
+ it ( 'should delete second' , function ( ) {
214
+ var datasource ;
215
+ inject ( function ( myResponsiveDatasource ) {
216
+ datasource = myResponsiveDatasource ;
217
+ } ) ;
218
+ runTest ( scrollSettings ,
219
+ function ( viewport , scope ) {
220
+
221
+ scrollBottom ( viewport , MAX ) ;
222
+
223
+ var initialTopHeight = getTopPaddingHeight ( viewport ) ;
224
+ removeItem ( datasource , datasource . min + 1 ) ;
225
+ scope . adapter . applyUpdates ( 2 , [ ] ) ;
226
+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( initialTopHeight - itemHeight * 1 ) ;
227
+
228
+ scrollTop ( viewport ) ;
229
+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
230
+ checkRow ( viewport , 1 , '1: item1' ) ;
231
+ checkRow ( viewport , 2 , '2: item3' ) ;
232
+ }
233
+ ) ;
234
+ } ) ;
235
+
189
236
} ) ;
190
237
191
238
describe ( 'removing inside the buffer\n' , ( ) => {
0 commit comments