Skip to content
Snippets Groups Projects
Unverified Commit 44fefc47 authored by aeschylus's avatar aeschylus Committed by GitHub
Browse files

Merge pull request #2031 from ProjectMirador/fix-next-canvas

fixes a bug where nextCanvas button wasn't getting disabled appropriately
parents 5a615f1b ff4b29f4
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,18 @@ describe('ViewerNavigation', () => { ...@@ -27,6 +27,18 @@ describe('ViewerNavigation', () => {
expect(setCanvas).toHaveBeenCalledWith('foo', 1); 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', () => { describe('when previous canvases are not present', () => {
it('disabled on previousCanvas button', () => { it('disabled on previousCanvas button', () => {
expect(wrapper.find('.mirador-previous-canvas-button').prop('disabled')).toBe(true); expect(wrapper.find('.mirador-previous-canvas-button').prop('disabled')).toBe(true);
...@@ -40,7 +52,7 @@ describe('ViewerNavigation', () => { ...@@ -40,7 +52,7 @@ describe('ViewerNavigation', () => {
it('setCanvas function is called after click for next', () => { it('setCanvas function is called after click for next', () => {
wrapper = shallow( wrapper = shallow(
<ViewerNavigation <ViewerNavigation
canvases={[1, 2]} canvases={[1, 2, 3]}
setCanvas={setCanvas} setCanvas={setCanvas}
window={{ id: 'foo', canvasIndex: 0, view: 'book' }} window={{ id: 'foo', canvasIndex: 0, view: 'book' }}
/>, />,
......
...@@ -29,7 +29,7 @@ export class ViewerNavigation extends Component { ...@@ -29,7 +29,7 @@ export class ViewerNavigation extends Component {
*/ */
hasNextCanvas() { hasNextCanvas() {
const { window, canvases } = this.props; const { window, canvases } = this.props;
return window.canvasIndex <= canvases.length - this.canvasIncrementor(); return window.canvasIndex < canvases.length - this.canvasIncrementor();
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment