@@ -6,7 +6,7 @@ describe('uiScroll Paddings cache', function () {
6
6
beforeEach ( module ( 'ui.scroll.test.datasources' ) ) ;
7
7
8
8
describe ( 'applyUpdates tests\n' , function ( ) {
9
- var itemsCount = 20 ;
9
+ var itemsCount = 30 ;
10
10
var itemHeight = 100 ;
11
11
var viewportHeight = 500 ;
12
12
var MAX = 999999 ;
@@ -56,15 +56,15 @@ describe('uiScroll Paddings cache', function () {
56
56
runTest ( scrollSettings ,
57
57
function ( viewport , scope ) {
58
58
59
- scrollBottom ( viewport , 2 ) ;
59
+ scrollBottom ( viewport , 3 ) ;
60
60
scrollTop ( viewport ) ;
61
61
62
62
var initialBottomHeight = getBottomPaddingHeight ( viewport ) ;
63
63
removeLastItem ( ) ;
64
64
scope . adapter . applyUpdates ( itemsCount , [ ] ) ;
65
65
expect ( getBottomPaddingHeight ( viewport ) ) . toBe ( initialBottomHeight - itemHeight ) ;
66
66
67
- scrollBottom ( viewport , 2 ) ;
67
+ scrollBottom ( viewport , 3 ) ;
68
68
expect ( viewport . scrollTop ( ) ) . toBe ( itemsCount * itemHeight - viewportHeight - itemHeight ) ;
69
69
}
70
70
) ;
@@ -82,7 +82,7 @@ describe('uiScroll Paddings cache', function () {
82
82
runTest ( scrollSettings ,
83
83
function ( viewport , scope ) {
84
84
85
- scrollBottom ( viewport , 2 ) ;
85
+ scrollBottom ( viewport , 3 ) ;
86
86
87
87
var initialTopHeight = getTopPaddingHeight ( viewport ) ;
88
88
removeFirstItem ( ) ;
@@ -95,6 +95,33 @@ describe('uiScroll Paddings cache', function () {
95
95
) ;
96
96
} ) ;
97
97
98
+ it ( 'should delete first row and then second row when out of buffer' , function ( ) {
99
+ var removeFirstItem ;
100
+ inject ( function ( myResponsiveDatasource ) {
101
+ var datasource = myResponsiveDatasource ;
102
+ removeFirstItem = function ( ) {
103
+ datasource . data . shift ( ) ;
104
+ datasource . min ++ ;
105
+ } ;
106
+ } ) ;
107
+ runTest ( scrollSettings ,
108
+ function ( viewport , scope ) {
109
+
110
+ scrollBottom ( viewport , 3 ) ;
111
+
112
+ var initialTopHeight = getTopPaddingHeight ( viewport ) ;
113
+ scope . adapter . applyUpdates ( 1 , [ ] ) ;
114
+ removeFirstItem ( ) ;
115
+ scope . adapter . applyUpdates ( 2 , [ ] ) ;
116
+ removeFirstItem ( ) ;
117
+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( initialTopHeight - itemHeight * 2 ) ;
118
+
119
+ scrollTop ( viewport ) ;
120
+ expect ( getTopPaddingHeight ( viewport ) ) . toBe ( 0 ) ;
121
+ }
122
+ ) ;
123
+ } ) ;
124
+
98
125
} ) ;
99
126
100
127
} ) ;
0 commit comments