Fix rounding error in output pagination controls

This commit is contained in:
Jake McDermott 2021-03-31 12:27:01 -04:00
parent 45d9ec94ad
commit 6047eb6172
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F
2 changed files with 8 additions and 1 deletions

View File

@ -6,7 +6,7 @@ export default function getRowRangePageSize(startIndex, stopIndex) {
page = startIndex + 1;
pageSize = 1;
} else if (stopIndex >= startIndex + 50) {
page = Math.ceil(startIndex / 50);
page = Math.floor(startIndex / 50) + 1;
pageSize = 50;
} else {
for (let i = stopIndex - startIndex + 1; i <= 50; i++) {

View File

@ -29,4 +29,11 @@ describe('getRowRangePageSize', () => {
firstIndex: 5,
});
});
test('handles range with 0 startIndex', () => {
expect(getRowRangePageSize(0, 50)).toEqual({
page: 1,
pageSize: 50,
firstIndex: 0,
});
});
});