@@ -56,10 +56,10 @@ describe('uiScroll Paddings cache', function () {
56
56
}
57
57
}
58
58
59
- function checkRow ( viewport , row , content ) {
59
+ function checkRow ( viewport , row , content , tail = false ) {
60
60
var children = viewport . children ( ) ;
61
- if ( row < 0 ) { // from the end
62
- row = children . length - 2 + row ;
61
+ if ( tail ) {
62
+ row = children . length - 1 - row ;
63
63
}
64
64
var rowElement = children [ row ] ;
65
65
expect ( rowElement . innerHTML ) . toBe ( content ) ;
@@ -98,7 +98,7 @@ describe('uiScroll Paddings cache', function () {
98
98
99
99
scrollBottom ( viewport , MAX ) ;
100
100
expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
101
- checkRow ( viewport , - 1 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) ) ;
101
+ checkRow ( viewport , 1 , ( itemsCount - 1 ) + ': item' + ( itemsCount - 1 ) , true ) ;
102
102
}
103
103
) ;
104
104
} ) ;
@@ -123,7 +123,31 @@ describe('uiScroll Paddings cache', function () {
123
123
124
124
scrollBottom ( viewport , MAX ) ;
125
125
expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight * 2 ) ;
126
- checkRow ( viewport , - 1 , ( itemsCount - 3 ) + ': item' + ( itemsCount - 3 ) ) ;
126
+ checkRow ( viewport , 1 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) , true ) ;
127
+ }
128
+ ) ;
129
+ } ) ;
130
+
131
+ it ( 'should delete pre-last row' , function ( ) {
132
+ var datasource ;
133
+ inject ( function ( myResponsiveDatasource ) {
134
+ datasource = myResponsiveDatasource ;
135
+ } ) ;
136
+ runTest ( scrollSettings ,
137
+ function ( viewport , scope ) {
138
+
139
+ scrollBottom ( viewport , MAX ) ;
140
+ scrollTop ( viewport ) ;
141
+
142
+ var initialBottomHeight = getBottomPaddingHeight ( viewport ) ;
143
+ removeItem ( datasource , datasource . max - 1 ) ;
144
+ scope . adapter . applyUpdates ( itemsCount - 1 , [ ] ) ;
145
+ expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( initialBottomHeight - itemHeight ) ;
146
+
147
+ scrollBottom ( viewport , MAX ) ;
148
+ expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
149
+ checkRow ( viewport , 1 , ( itemsCount - 1 ) + ': item' + itemsCount , true ) ;
150
+ checkRow ( viewport , 2 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) , true ) ;
127
151
}
128
152
) ;
129
153
} ) ;
@@ -174,6 +198,29 @@ describe('uiScroll Paddings cache', function () {
174
198
) ;
175
199
} ) ;
176
200
201
+ it ( 'should delete second' , function ( ) {
202
+ var datasource ;
203
+ inject ( function ( myResponsiveDatasource ) {
204
+ datasource = myResponsiveDatasource ;
205
+ } ) ;
206
+ runTest ( scrollSettings ,
207
+ function ( viewport , scope ) {
208
+
209
+ scrollBottom ( viewport , MAX ) ;
210
+
211
+ var initialTopHeight = getTopPaddingHeight ( viewport ) ;
212
+ removeItem ( datasource , datasource . min + 1 ) ;
213
+ scope . adapter . applyUpdates ( 2 , [ ] ) ;
214
+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( initialTopHeight - itemHeight * 1 ) ;
215
+
216
+ scrollTop ( viewport ) ;
217
+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
218
+ checkRow ( viewport , 1 , '1: item1' ) ;
219
+ checkRow ( viewport , 2 , '2: item3' ) ;
220
+ }
221
+ ) ;
222
+ } ) ;
223
+
177
224
} ) ;
178
225
179
226
describe ( 'removing inside the buffer\n' , function ( ) {
0 commit comments