Skip to content

Commit

Permalink
fix: 🐛 added unit testing for lastRowCol in cellNav and loadData
Browse files Browse the repository at this point in the history
  • Loading branch information
moeyang13 authored and mportuga committed Jul 31, 2023
1 parent 5200747 commit 3061ab2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/infinite-scroll/test/infiniteScroll.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,45 @@
expect(grid.api.infiniteScroll.raise.needLoadMoreData).not.toHaveBeenCalled();
});
});
describe('cellNav and loadData', function() {
var arrayOf50 = [];
var VisibleRowCount = 50;
var lastRowIndex = 49;
beforeEach(function() {
grid.infiniteScroll = undefined;
uiGridInfiniteScrollService.initializeGrid(grid, $scope);
spyOn(grid, 'getVisibleRowCount').and.returnValue(VisibleRowCount);
spyOn(grid.api.infiniteScroll.raise, 'needLoadMoreData');
spyOn(grid.api.infiniteScroll.raise, 'needLoadMoreDataTop');
for ( var i = 0; i < VisibleRowCount; i++ ) {
arrayOf50.push(i);
}
grid.cellNav = {
lastRowCol: {
row: {
index: 0
}
}
};
grid.renderContainers = { body: { visibleRowCache: arrayOf50}};
});
afterEach(function() {
grid.api.infiniteScroll.raise.needLoadMoreData.calls.reset();
grid.api.infiniteScroll.raise.needLoadMoreDataTop.calls.reset();
});
it('scroll down and last row is currently selected', function() {
grid.scrollDirection = uiGridConstants.scrollDirection.DOWN;
grid.infiniteScroll.scrollDown = true;
grid.cellNav.lastRowCol.row.index = lastRowIndex;

uiGridInfiniteScrollService.loadData(grid);

expect(grid.infiniteScroll.previousVisibleRows).toEqual(grid.getVisibleRowCount());
expect(grid.api.infiniteScroll.raise.needLoadMoreData).not.toHaveBeenCalled();
expect(grid.infiniteScroll.direction).toEqual(uiGridConstants.scrollDirection.DOWN);
});
});

describe('handleScroll', function() {
describe('when the source is the even "ui.grid.adjustInfiniteScrollPosition"', function() {
beforeEach(function() {
Expand Down

0 comments on commit 3061ab2

Please sign in to comment.