From 46caf319c36d90150ad3e9bc2b0d16edaa434b40 Mon Sep 17 00:00:00 2001 From: Adam Zarger Date: Thu, 24 Jan 2019 13:58:56 -0500 Subject: [PATCH 1/2] Calculate correct pagination with new size limit --- src/Pagination.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Pagination.jsx b/src/Pagination.jsx index 3d6d07353..20545c8bb 100644 --- a/src/Pagination.jsx +++ b/src/Pagination.jsx @@ -20,7 +20,10 @@ export class Pagination extends React.Component { _calculatePages( props ) { const from = props.from || 0; - const size = props.size || 1; + var size = props.size || 1; + if ( size > 100 ) { + size = 100; + } const total = props.total || 0; const c = Math.ceil( from / size ) + 1; From 188c46f735826429458690a47aaa3ba3fd130967 Mon Sep 17 00:00:00 2001 From: Adam Zarger Date: Fri, 25 Jan 2019 09:09:51 -0500 Subject: [PATCH 2/2] Unit test for size limit --- src/__tests__/Pagination.spec.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/__tests__/Pagination.spec.jsx b/src/__tests__/Pagination.spec.jsx index be710ab63..bbf6bfcdf 100644 --- a/src/__tests__/Pagination.spec.jsx +++ b/src/__tests__/Pagination.spec.jsx @@ -74,6 +74,13 @@ it('records text input from the user', () => { expect(target.state('inputValue')).toEqual(49) }) +it('corrects large size to size limit', () => { + const target = shallow() + + // Expect 1000 / 100 + expect(target.state('total')).toEqual(10) +}) + describe('disabled buttons', () => { it('disables the previous button when on the first page', () => { const target = shallow()