From ff4b29f46586862482ed6dcf900a9743157d1533 Mon Sep 17 00:00:00 2001 From: Jack Reed <phillipjreed@gmail.com> Date: Fri, 1 Mar 2019 17:13:16 -0700 Subject: [PATCH] fixes a bug where nextCanvas button wasnt getting disabled appropriately --- __tests__/src/components/ViewerNavigation.test.js | 14 +++++++++++++- src/components/ViewerNavigation.js | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/__tests__/src/components/ViewerNavigation.test.js b/__tests__/src/components/ViewerNavigation.test.js index fc348f83a..c6d751504 100644 --- a/__tests__/src/components/ViewerNavigation.test.js +++ b/__tests__/src/components/ViewerNavigation.test.js @@ -27,6 +27,18 @@ describe('ViewerNavigation', () => { expect(setCanvas).toHaveBeenCalledWith('foo', 1); }); }); + describe('when next canvases are not present', () => { + it('nextCanvas button is disabled', () => { + const endWrapper = shallow( + <ViewerNavigation + canvases={[1, 2]} + setCanvas={() => {}} + window={{ id: 'foo', canvasIndex: 1 }} + />, + ); + expect(endWrapper.find('.mirador-next-canvas-button').prop('disabled')).toBe(true); + }); + }); describe('when previous canvases are not present', () => { it('disabled on previousCanvas button', () => { expect(wrapper.find('.mirador-previous-canvas-button').prop('disabled')).toBe(true); @@ -40,7 +52,7 @@ describe('ViewerNavigation', () => { it('setCanvas function is called after click for next', () => { wrapper = shallow( <ViewerNavigation - canvases={[1, 2]} + canvases={[1, 2, 3]} setCanvas={setCanvas} window={{ id: 'foo', canvasIndex: 0, view: 'book' }} />, diff --git a/src/components/ViewerNavigation.js b/src/components/ViewerNavigation.js index 126c1f4c6..b366e0961 100644 --- a/src/components/ViewerNavigation.js +++ b/src/components/ViewerNavigation.js @@ -29,7 +29,7 @@ export class ViewerNavigation extends Component { */ hasNextCanvas() { const { window, canvases } = this.props; - return window.canvasIndex <= canvases.length - this.canvasIncrementor(); + return window.canvasIndex < canvases.length - this.canvasIncrementor(); } /** -- GitLab