Skip to content

Commit c4ff41b

Browse files
committed
new test for removing out-of-buffer: remove after remove (top)
1 parent 9790d45 commit c4ff41b

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

test/PaddingCacheSpec.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('uiScroll Paddings cache', function () {
66
beforeEach(module('ui.scroll.test.datasources'));
77

88
describe('applyUpdates tests\n', function () {
9-
var itemsCount = 20;
9+
var itemsCount = 30;
1010
var itemHeight = 100;
1111
var viewportHeight = 500;
1212
var MAX = 999999;
@@ -56,15 +56,15 @@ describe('uiScroll Paddings cache', function () {
5656
runTest(scrollSettings,
5757
function (viewport, scope) {
5858

59-
scrollBottom(viewport, 2);
59+
scrollBottom(viewport, 3);
6060
scrollTop(viewport);
6161

6262
var initialBottomHeight = getBottomPaddingHeight(viewport);
6363
removeLastItem();
6464
scope.adapter.applyUpdates(itemsCount, []);
6565
expect(getBottomPaddingHeight(viewport)).toBe(initialBottomHeight - itemHeight);
6666

67-
scrollBottom(viewport, 2);
67+
scrollBottom(viewport, 3);
6868
expect(viewport.scrollTop()).toBe(itemsCount * itemHeight - viewportHeight - itemHeight );
6969
}
7070
);
@@ -82,7 +82,7 @@ describe('uiScroll Paddings cache', function () {
8282
runTest(scrollSettings,
8383
function (viewport, scope) {
8484

85-
scrollBottom(viewport, 2);
85+
scrollBottom(viewport, 3);
8686

8787
var initialTopHeight = getTopPaddingHeight(viewport);
8888
removeFirstItem();
@@ -95,6 +95,33 @@ describe('uiScroll Paddings cache', function () {
9595
);
9696
});
9797

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+
98125
});
99126

100127
});

test/datasources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ angular.module('ui.scroll.test.datasources', [])
199199
var datasource = {
200200
data: [],
201201
min: 1,
202-
max: 20,
202+
max: 30,
203203
init: function() {
204204
for (var i = this.min; i <= this.max; i++) {
205205
this.data.push('item' + i);

0 commit comments

Comments
 (0)