Merge pull request #9773 from jakemcdermott/fix-9772

Fix rounding error in output pagination controls

for #9772

Reviewed-by: Jake McDermott <yo@jakemcdermott.me>
Reviewed-by: Kersom <None>
Reviewed-by: Tiago Góes <tiago.goes2009@gmail.com>
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-03-31 19:01:11 +00:00 committed by GitHub
commit 5eae035f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,
});
});
});