diff --git a/__tests__/src/components/ViewerNavigation.test.js b/__tests__/src/components/ViewerNavigation.test.js index fc348f83a6a8ce3587a7af0986d0572944f07071..c6d751504959fdd560aea66be972c955a0064c01 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 126c1f4c68b21236a288e07e06f6ec9e7230d1ca..b366e0961ea342b1f85a9e8378370ad90c8586ec 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(); } /**