Skip to content

Commit

Permalink
update usage to show isLastPage now works correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Jun 3, 2020
1 parent 68b1dfe commit 19873e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/components/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Pagination extends Component {
return this.pageLink({
ariaLabel: 'Previous',
additionalClassName: this.props.cssClasses.previousPageItem,
isDisabled: this.props.nbHits === 0 || isFirstPage,
isDisabled: isFirstPage,
label: this.props.templates.previous,
pageNumber: currentPage - 1,
createURL,
Expand All @@ -59,7 +59,7 @@ class Pagination extends Component {
return this.pageLink({
ariaLabel: 'Next',
additionalClassName: this.props.cssClasses.nextPageItem,
isDisabled: this.props.nbHits === 0 || isLastPage,
isDisabled: isLastPage,
label: this.props.templates.next,
pageNumber: currentPage + 1,
createURL,
Expand All @@ -70,7 +70,7 @@ class Pagination extends Component {
return this.pageLink({
ariaLabel: 'First',
additionalClassName: this.props.cssClasses.firstPageItem,
isDisabled: this.props.nbHits === 0 || isFirstPage,
isDisabled: isFirstPage,
label: this.props.templates.first,
pageNumber: 0,
createURL,
Expand All @@ -81,7 +81,7 @@ class Pagination extends Component {
return this.pageLink({
ariaLabel: 'Last',
additionalClassName: this.props.cssClasses.lastPageItem,
isDisabled: this.props.nbHits === 0 || isLastPage,
isDisabled: isLastPage,
label: this.props.templates.last,
pageNumber: nbPages - 1,
createURL,
Expand Down
9 changes: 8 additions & 1 deletion src/components/Pagination/__tests__/Pagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ describe('Pagination', () => {
});

it('should have all buttons disabled if there are no results', () => {
const localPager = new Paginator({
currentPage: 0,
total: 0,
padding: 3,
});
const wrapper = mount(
<Pagination
{...defaultProps}
Expand All @@ -109,7 +114,9 @@ describe('Pagination', () => {
currentPage={0}
nbHits={0}
nbPages={0}
pages={[0]}
pages={localPager.pages()}
isFirstPage={localPager.isFirstPage()}
isLastPage={localPager.isLastPage()}
/>
);

Expand Down

0 comments on commit 19873e4

Please sign in to comment.