@@ -92,6 +92,10 @@ describe('uiScroll Paddings spec.', () => {
9292 expect ( rowElement . innerHTML ) . toBe ( content ) ;
9393 }
9494
95+ function checkRowBack ( viewport , row , content ) {
96+ checkRow ( viewport , row , content , true ) ;
97+ }
98+
9599 it ( '\nshould set up properly' , ( ) => {
96100 runTest ( scrollSettings ,
97101 ( ) => {
@@ -121,7 +125,7 @@ describe('uiScroll Paddings spec.', () => {
121125 ! outside && scrollTop ( viewport ) ;
122126 scrollBottom ( viewport , MAX ) ;
123127 expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
124- checkRow ( viewport , 1 , ( itemsCount - 1 ) + ': item' + ( itemsCount - 1 ) , true ) ;
128+ checkRowBack ( viewport , 1 , ( itemsCount - 1 ) + ': item' + ( itemsCount - 1 ) ) ;
125129 }
126130 )
127131 )
@@ -148,7 +152,7 @@ describe('uiScroll Paddings spec.', () => {
148152 ! outside && scrollTop ( viewport ) ;
149153 scrollBottom ( viewport , MAX ) ;
150154 expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight * 2 ) ;
151- checkRow ( viewport , 1 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) , true ) ;
155+ checkRowBack ( viewport , 1 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) ) ;
152156 }
153157 )
154158 )
@@ -173,8 +177,8 @@ describe('uiScroll Paddings spec.', () => {
173177 ! outside && scrollTop ( viewport ) ;
174178 scrollBottom ( viewport , MAX ) ;
175179 expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
176- checkRow ( viewport , 1 , ( itemsCount - 1 ) + ': item' + itemsCount , true ) ;
177- checkRow ( viewport , 2 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) , true ) ;
180+ checkRowBack ( viewport , 1 , ( itemsCount - 1 ) + ': item' + itemsCount ) ;
181+ checkRowBack ( viewport , 2 , ( itemsCount - 2 ) + ': item' + ( itemsCount - 2 ) ) ;
178182 }
179183 )
180184 )
@@ -250,7 +254,7 @@ describe('uiScroll Paddings spec.', () => {
250254 outside && expect ( getTopPaddingHeight ( viewport ) ) . toBe ( initialTopHeight - itemHeight * 1 ) ;
251255
252256 ! outside && scrollBottom ( viewport , MAX ) ;
253- expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( 0 ) ; // todo dhilt : needs to be fixed
257+ expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
254258
255259 scrollTop ( viewport ) ;
256260 expect ( getTopPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
@@ -282,10 +286,10 @@ describe('uiScroll Paddings spec.', () => {
282286 scrollBottom ( viewport ) ;
283287 expect ( viewport . scrollTop ( ) ) . toBe ( _scrollTop + newItems . length * itemHeight ) ;
284288
285- checkRow ( viewport , 1 , ( datasource . max - 0 ) + ': ' + newItems [ 2 ] , true ) ;
286- checkRow ( viewport , 2 , ( datasource . max - 1 ) + ': ' + newItems [ 1 ] , true ) ;
287- checkRow ( viewport , 3 , ( datasource . max - 2 ) + ': ' + newItems [ 0 ] , true ) ;
288- checkRow ( viewport , 4 , oldMax + ': item' + oldMax , true ) ;
289+ checkRowBack ( viewport , 1 , ( datasource . max - 0 ) + ': ' + newItems [ 2 ] ) ;
290+ checkRowBack ( viewport , 2 , ( datasource . max - 1 ) + ': ' + newItems [ 1 ] ) ;
291+ checkRowBack ( viewport , 3 , ( datasource . max - 2 ) + ': ' + newItems [ 0 ] ) ;
292+ checkRowBack ( viewport , 4 , oldMax + ': item' + oldMax ) ;
289293 }
290294 ) ;
291295 } ) ;
@@ -310,13 +314,59 @@ describe('uiScroll Paddings spec.', () => {
310314 scrollBottom ( viewport ) ;
311315 expect ( viewport . scrollTop ( ) ) . toBe ( _scrollTop + newItems . length * itemHeight ) ;
312316
313- checkRow ( viewport , 1 , ( datasource . max - 0 ) + ': ' + newItems [ 2 ] , true ) ;
314- checkRow ( viewport , 2 , ( datasource . max - 1 ) + ': ' + newItems [ 1 ] , true ) ;
315- checkRow ( viewport , 3 , ( datasource . max - 2 ) + ': ' + newItems [ 0 ] , true ) ;
316- checkRow ( viewport , 4 , oldMax + ': item' + oldMax , true ) ;
317+ checkRowBack ( viewport , 1 , ( datasource . max - 0 ) + ': ' + newItems [ 2 ] ) ;
318+ checkRowBack ( viewport , 2 , ( datasource . max - 1 ) + ': ' + newItems [ 1 ] ) ;
319+ checkRowBack ( viewport , 3 , ( datasource . max - 2 ) + ': ' + newItems [ 0 ] ) ;
320+ checkRowBack ( viewport , 4 , oldMax + ': item' + oldMax ) ;
317321 }
318322 ) ;
319323 } ) ;
320324 } ) ;
321325
326+
327+ describe ( 'Removing items via indexed-based applyUpdates when neither BOF nor EOF are reached\n' , ( ) => {
328+
329+ [ true , false ] . forEach ( userIndicies =>
330+ it ( 'should remove first row' + appendTitle ( true , userIndicies ) , ( ) =>
331+ runTest ( Object . assign ( { } , scrollSettings , { startIndex : 12 } ) ,
332+ ( viewport , scope ) => {
333+ userIndicies && setUserIndicies ( ) ;
334+
335+ removeItem ( datasource , 2 ) ;
336+ scope . adapter . applyUpdates ( 2 , [ ] ) ;
337+
338+ scrollBottom ( viewport ) ;
339+ expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
340+ checkRowBack ( viewport , 1 , '29: item30' ) ;
341+
342+ scrollTop ( viewport ) ;
343+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
344+ checkRow ( viewport , 1 , '1: item1' ) ;
345+ checkRow ( viewport , 2 , '2: item3' ) ;
346+ }
347+ )
348+ )
349+ ) ;
350+
351+ [ true , false ] . forEach ( userIndicies =>
352+ it ( 'should remove last row' + appendTitle ( true , userIndicies ) , ( ) =>
353+ runTest ( Object . assign ( { } , scrollSettings , { startIndex : 12 } ) ,
354+ ( viewport , scope ) => {
355+ userIndicies && setUserIndicies ( ) ;
356+
357+ removeItem ( datasource , 19 ) ;
358+ scope . adapter . applyUpdates ( 19 , [ ] ) ;
359+
360+ scrollBottom ( viewport ) ;
361+ expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
362+ checkRowBack ( viewport , 1 , '29: item30' ) ;
363+
364+ scrollTop ( viewport ) ;
365+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
366+ }
367+ )
368+ )
369+ ) ;
370+ } ) ;
371+
322372} ) ;
0 commit comments