mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
parent
3ec849bd94
commit
528be5c058
@ -40,8 +40,8 @@ export default ExtendBase =>
|
||||
|
||||
let from = ((currPage - pageStartIndex) * currSizePerPage);
|
||||
from = dataSize === 0 ? 0 : from + 1;
|
||||
let to = Math.min((currSizePerPage * (currPage + offset) - 1), dataSize);
|
||||
if (to >= dataSize) to -= 1;
|
||||
let to = Math.min(currSizePerPage * (currPage + offset), dataSize);
|
||||
if (to > dataSize) to = dataSize;
|
||||
|
||||
return [from, to];
|
||||
}
|
||||
|
||||
@ -119,7 +119,34 @@ describe('PageResolver', () => {
|
||||
|
||||
it('should return correct array with from and to value', () => {
|
||||
const instance = wrapper.instance();
|
||||
expect(instance.calculateFromTo()).toEqual([1, props.currSizePerPage - 1]);
|
||||
expect(instance.calculateFromTo()).toEqual([1, props.currSizePerPage]);
|
||||
});
|
||||
|
||||
describe('if data is empty', () => {
|
||||
beforeEach(() => {
|
||||
props.dataSize = 87;
|
||||
props.currPage = 9;
|
||||
const mockElement = React.createElement(MockComponent, props, null);
|
||||
wrapper = shallow(mockElement);
|
||||
});
|
||||
|
||||
it('should return correct array with from and to value', () => {
|
||||
const instance = wrapper.instance();
|
||||
expect(instance.calculateFromTo()).toEqual([81, props.dataSize]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('if current page is last page', () => {
|
||||
beforeEach(() => {
|
||||
props.dataSize = 0;
|
||||
const mockElement = React.createElement(MockComponent, props, null);
|
||||
wrapper = shallow(mockElement);
|
||||
});
|
||||
|
||||
it('should return correct array with from and to value', () => {
|
||||
const instance = wrapper.instance();
|
||||
expect(instance.calculateFromTo()).toEqual([0, 0]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user