* updated test for pagination fix

* suspected bug in page.js

Local pagination aligning returns start page when eg editing cell locally. This results in state change, too. Not really getting the purpose of the original idea. Please consider this modification. It only checks if page fits in the data size range. As I saw, this alignment only affects local pagination, not remote.

* modified fix w/ pageStartIndex

I forgot to mind pageStartIndex
This commit is contained in:
copas2 2018-08-16 11:16:47 +02:00 committed by Allen
parent cb49455a4e
commit 4a3486cc3c
2 changed files with 3 additions and 4 deletions

View File

@ -23,10 +23,9 @@ export const alignPage = (
sizePerPage,
pageStartIndex
) => {
const end = endIndex(page, sizePerPage, pageStartIndex);
const dataSize = data.length;
if (end - 1 > dataSize) {
if (page < pageStartIndex || page > (Math.floor(dataSize / sizePerPage) + pageStartIndex)) {
return pageStartIndex;
}
return page;

View File

@ -45,8 +45,8 @@ describe('Page Functions', () => {
describe('alignPage', () => {
const pageStartIndex = 1;
const sizePerPage = 10;
const page = 2;
describe('if the length of store.data is less than the end page index', () => {
const page = 3;
describe('if the page does not fit the pages interval calculated from the length of store.data', () => {
beforeEach(() => {
data = [];
for (let i = 0; i < 15; i += 1) {