Skip to content

Commit 9fb9ffc

Browse files
committed
2 tests on appending some rows with and without min/max indicies setting
1 parent a312083 commit 9fb9ffc

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

test/PaddingsSpec.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,61 @@ describe('uiScroll Paddings spec.', () => {
255255
});
256256
});
257257

258+
describe('Appending inside the buffer\n', () => {
259+
260+
it('should append 3 rows via index-based applyUpdates', () => {
261+
runTest(Object.assign({}, scrollSettings, { startIndex: 28 }),
262+
(viewport, scope) => {
263+
const newItems = [
264+
'item' + (datasource.max + 1),
265+
'item' + (datasource.max + 2),
266+
'item' + (datasource.max + 3)
267+
];
268+
const oldMax = datasource.max;
269+
const _scrollTop = viewport.scrollTop();
270+
271+
insertItems(datasource, datasource.max, newItems);
272+
scope.adapter.applyUpdates(oldMax, ['item' + oldMax, ...newItems]);
273+
274+
scrollBottom(viewport);
275+
expect(viewport.scrollTop()).toBe(_scrollTop + newItems.length * itemHeight);
276+
277+
checkRow(viewport, 1, (datasource.max - 0) + ': ' + newItems[2], true);
278+
checkRow(viewport, 2, (datasource.max - 1) + ': ' + newItems[1], true);
279+
checkRow(viewport, 3, (datasource.max - 2) + ': ' + newItems[0], true);
280+
checkRow(viewport, 4, oldMax + ': item' + oldMax, true);
281+
}
282+
);
283+
});
284+
285+
// it('should append 3 rows via index-based applyUpdates when min/max indicies are set', () => {
286+
// runTest(Object.assign({}, scrollSettings, { startIndex: 28 }),
287+
// (viewport, scope) => {
288+
// const newItems = [
289+
// 'item' + (datasource.max + 1),
290+
// 'item' + (datasource.max + 2),
291+
// 'item' + (datasource.max + 3)
292+
// ];
293+
// const oldMax = datasource.max;
294+
// const _scrollTop = viewport.scrollTop();
295+
296+
// datasource.minIndex = datasource.min;
297+
// datasource.maxIndex = datasource.max;
298+
299+
// insertItems(datasource, datasource.max, newItems);
300+
// scope.adapter.applyUpdates(oldMax, ['item' + oldMax, ...newItems]);
301+
302+
// scrollBottom(viewport);
303+
// expect(viewport.scrollTop()).toBe(_scrollTop + newItems.length * itemHeight);
304+
305+
// checkRow(viewport, 1, (datasource.max - 0) + ': ' + newItems[2], true);
306+
// checkRow(viewport, 2, (datasource.max - 1) + ': ' + newItems[1], true);
307+
// checkRow(viewport, 3, (datasource.max - 2) + ': ' + newItems[0], true);
308+
// checkRow(viewport, 4, oldMax + ': item' + oldMax, true);
309+
// }
310+
// );
311+
// });
312+
313+
});
314+
258315
});

0 commit comments

Comments
 (0)