Skip to content
Snippets Groups Projects
Commit 1530917a authored by Glenn Fischer's avatar Glenn Fischer Committed by Mathias Maaß
Browse files

2128 enable sort keys in eslint (#2276)

* #2128: adds sort-keys to eslint rules, reorders keys

* fix tests
parent 3825f448
No related branches found
No related tags found
No related merge requests found
Showing
with 244 additions and 118 deletions
......@@ -22,6 +22,10 @@
"FunctionExpression": true
}
}],
"react/prefer-stateless-function": "off"
"react/prefer-stateless-function": "off",
"sort-keys": ["error", "asc", {
"caseSensitive": false,
"natural": false
}]
}
}
......@@ -13,9 +13,9 @@ describe('annotation actions', () => {
const canvasId = 'foo';
const annotationId = 'abc123';
const expectedAction = {
type: ActionTypes.REQUEST_ANNOTATION,
canvasId,
annotationId,
canvasId,
type: ActionTypes.REQUEST_ANNOTATION,
};
expect(actions.requestAnnotation(canvasId, annotationId)).toEqual(expectedAction);
});
......@@ -29,10 +29,10 @@ describe('annotation actions', () => {
content: 'annotation request',
};
const expectedAction = {
type: ActionTypes.RECEIVE_ANNOTATION,
canvasId,
annotationId,
annotationJson: json,
canvasId,
type: ActionTypes.RECEIVE_ANNOTATION,
};
expect(actions.receiveAnnotation(canvasId, annotationId, json)).toEqual(expectedAction);
});
......@@ -53,8 +53,8 @@ describe('annotation actions', () => {
));
expect(store.getActions()).toEqual([
{
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
annotationId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
type: 'REQUEST_ANNOTATION',
},
]);
......@@ -68,14 +68,14 @@ describe('annotation actions', () => {
const expectedActions = store.getActions();
expect(expectedActions).toEqual([
{
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
annotationId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
type: 'REQUEST_ANNOTATION',
},
{
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
annotationId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
annotationJson: { data: '12345' },
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
type: 'RECEIVE_ANNOTATION',
},
]);
......@@ -92,13 +92,13 @@ describe('annotation actions', () => {
const expectedActions = store.getActions();
expect(expectedActions).toEqual([
{
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
annotationId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
type: 'REQUEST_ANNOTATION',
},
{
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
annotationId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896',
error: new Error('invalid json response body at undefined reason: Unexpected end of JSON input'),
type: 'RECEIVE_ANNOTATION_FAILURE',
},
......@@ -113,10 +113,10 @@ describe('annotation actions', () => {
const canvasId = 'cId1';
const annotationId = 'aId1';
const expectedAction = {
annotationId,
canvasId,
type: ActionTypes.SELECT_ANNOTATION,
windowId,
canvasId,
annotationId,
};
expect(actions.selectAnnotation(windowId, canvasId, annotationId)).toEqual(expectedAction);
});
......@@ -126,10 +126,10 @@ describe('annotation actions', () => {
const canvasId = 'cId1';
const annotationId = 'aId1';
const expectedAction = {
annotationId,
canvasId,
type: ActionTypes.DESELECT_ANNOTATION,
windowId,
canvasId,
annotationId,
};
expect(actions.deselectAnnotation(windowId, canvasId, annotationId)).toEqual(expectedAction);
});
......
......@@ -8,9 +8,9 @@ describe('canvas actions', () => {
it('sets to a defined canvas', () => {
const id = 'abc123';
const expectedAction = {
canvasIndex: 100,
type: ActionTypes.SET_CANVAS,
windowId: id,
canvasIndex: 100,
};
expect(actions.setCanvas(id, 100)).toEqual(expectedAction);
});
......@@ -24,13 +24,13 @@ describe('canvas actions', () => {
time: debounceTime,
},
},
type: ActionTypes.UPDATE_VIEWPORT,
windowId: id,
payload: {
x: 1,
y: 0,
zoom: 0.5,
},
type: ActionTypes.UPDATE_VIEWPORT,
windowId: id,
};
expect(actions.updateViewport(id, { x: 1, y: 0, zoom: 0.5 })).toEqual(expectedAction);
});
......
......@@ -6,14 +6,14 @@ describe('companionWindow actions', () => {
it('should return correct action object', () => {
const payload = {
content: 'info',
position: 'right',
foo: 'bar',
position: 'right',
};
const mockState = {
companionWindows: {},
windows: {
abc123: { companionWindowIds: [] },
},
companionWindows: {},
};
const mockDispatch = jest.fn(() => ({}));
......@@ -33,10 +33,10 @@ describe('companionWindow actions', () => {
const defaults = { foo: 'bar' };
const mockState = {
companionWindows: {},
windows: {
abc123: { companionWindowIds: [] },
},
companionWindows: {},
};
const mockDispatch = jest.fn(() => ({}));
......@@ -53,10 +53,10 @@ describe('companionWindow actions', () => {
const payload = {};
const mockState = {
companionWindows: {},
windows: {
abc123: { companionWindowIds: [] },
},
companionWindows: {},
};
const mockDispatch = jest.fn(() => ({}));
......@@ -76,8 +76,8 @@ describe('companionWindow actions', () => {
it('should return correct action object', () => {
const payload = {
content: 'info',
position: 'right',
foo: 'bar',
position: 'right',
};
const action = actions.updateCompanionWindow('abc123', 'cw-123', payload);
......
......@@ -6,8 +6,8 @@ describe('config actions', () => {
it('sets the config', () => {
const config = { foo: 'bar' };
const expectedAction = {
type: ActionTypes.SET_CONFIG,
config,
type: ActionTypes.SET_CONFIG,
};
expect(actions.setConfig(config)).toEqual(expectedAction);
});
......@@ -16,8 +16,8 @@ describe('config actions', () => {
it('updates the config', () => {
const config = { foo: 'bar' };
const expectedAction = {
type: ActionTypes.UPDATE_CONFIG,
config,
type: ActionTypes.UPDATE_CONFIG,
};
expect(actions.updateConfig(config)).toEqual(expectedAction);
});
......
......@@ -12,8 +12,8 @@ describe('infoResponse actions', () => {
it('requests an infoResponse from given a url', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.REQUEST_INFO_RESPONSE,
infoId: id,
type: ActionTypes.REQUEST_INFO_RESPONSE,
};
expect(actions.requestInfoResponse(id)).toEqual(expectedAction);
});
......@@ -22,13 +22,13 @@ describe('infoResponse actions', () => {
it('recieves an infoResponse', () => {
const id = 'abc123';
const json = {
id,
content: 'image information request',
id,
};
const expectedAction = {
type: ActionTypes.RECEIVE_INFO_RESPONSE,
infoId: id,
infoJson: json,
type: ActionTypes.RECEIVE_INFO_RESPONSE,
};
expect(actions.receiveInfoResponse(id, json)).toEqual(expectedAction);
});
......@@ -66,7 +66,7 @@ describe('infoResponse actions', () => {
const expectedActions = store.getActions();
expect(expectedActions).toEqual([
{ infoId: 'https://stacks.stanford.edu/image/iiif/sn904cj3429%2F12027000/info.json', type: 'REQUEST_INFO_RESPONSE' },
{ infoId: 'https://stacks.stanford.edu/image/iiif/sn904cj3429%2F12027000/info.json', error: new Error('invalid json response body at undefined reason: Unexpected end of JSON input'), type: 'RECEIVE_INFO_RESPONSE_FAILURE' },
{ error: new Error('invalid json response body at undefined reason: Unexpected end of JSON input'), infoId: 'https://stacks.stanford.edu/image/iiif/sn904cj3429%2F12027000/info.json', type: 'RECEIVE_INFO_RESPONSE_FAILURE' },
]);
});
});
......@@ -75,8 +75,8 @@ describe('infoResponse actions', () => {
describe('removeInfoResponse', () => {
it('removes an existing infoResponse', () => {
const expectedAction = {
type: ActionTypes.REMOVE_INFO_RESPONSE,
infoId: 'foo',
type: ActionTypes.REMOVE_INFO_RESPONSE,
};
expect(actions.removeInfoResponse('foo')).toEqual(expectedAction);
});
......
......@@ -12,8 +12,8 @@ describe('manifest actions', () => {
it('requests a manifest given a url', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.REQUEST_MANIFEST,
manifestId: id,
type: ActionTypes.REQUEST_MANIFEST,
};
expect(actions.requestManifest(id)).toEqual(expectedAction);
});
......@@ -22,13 +22,13 @@ describe('manifest actions', () => {
it('receives a manifest', () => {
const id = 'abc123';
const json = {
id,
content: 'lots of metadata, canvases, and other IIIFy things',
id,
};
const expectedAction = {
type: ActionTypes.RECEIVE_MANIFEST,
manifestId: id,
manifestJson: json,
type: ActionTypes.RECEIVE_MANIFEST,
};
expect(actions.receiveManifest(id, json)).toEqual(expectedAction);
});
......@@ -45,7 +45,11 @@ describe('manifest actions', () => {
it('dispatches the REQUEST_MANIFEST action', () => {
store.dispatch(actions.fetchManifest('https://purl.stanford.edu/sn904cj3429/iiif/manifest'));
expect(store.getActions()).toEqual([
{ manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest', type: 'REQUEST_MANIFEST', properties: { isFetching: true } },
{
manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest',
properties: { isFetching: true },
type: 'REQUEST_MANIFEST',
},
]);
});
it('dispatches the REQUEST_MANIFEST and then RECEIVE_MANIFEST', () => {
......@@ -53,8 +57,16 @@ describe('manifest actions', () => {
.then(() => {
const expectedActions = store.getActions();
expect(expectedActions).toEqual([
{ manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest', type: 'REQUEST_MANIFEST', properties: { isFetching: true } },
{ manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest', manifestJson: { data: '12345' }, type: 'RECEIVE_MANIFEST' },
{
manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest',
properties: { isFetching: true },
type: 'REQUEST_MANIFEST',
},
{
manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest',
manifestJson: { data: '12345' },
type: 'RECEIVE_MANIFEST',
},
]);
});
});
......@@ -65,8 +77,16 @@ describe('manifest actions', () => {
.then(() => {
const expectedActions = store.getActions();
expect(expectedActions).toEqual([
{ manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest', type: 'REQUEST_MANIFEST', properties: { isFetching: true } },
{ manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest', error: 'FetchError: invalid json response body at undefined reason: Unexpected end of JSON input', type: 'RECEIVE_MANIFEST_FAILURE' },
{
manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest',
properties: { isFetching: true },
type: 'REQUEST_MANIFEST',
},
{
error: 'FetchError: invalid json response body at undefined reason: Unexpected end of JSON input',
manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest',
type: 'RECEIVE_MANIFEST_FAILURE',
},
]);
});
});
......@@ -75,8 +95,8 @@ describe('manifest actions', () => {
describe('removeManifest', () => {
it('removes an existing manifest', () => {
const expectedAction = {
type: ActionTypes.REMOVE_MANIFEST,
manifestId: 'foo',
type: ActionTypes.REMOVE_MANIFEST,
};
expect(actions.removeManifest('foo')).toEqual(expectedAction);
});
......
......@@ -5,22 +5,25 @@ describe('window actions', () => {
describe('focusWindow', () => {
it('should return correct action object with pan=true', () => {
const expectedAction = {
position: { x: 25, y: -13 },
type: ActionTypes.FOCUS_WINDOW,
windowId: 'window',
position: { x: 25, y: -13 },
};
const mockState = {
companionWindows: {},
windows: {
window: {
x: 50, y: 12, width: 50, height: 50,
height: 50,
width: 50,
x: 50,
y: 12,
},
},
companionWindows: {},
workspace: {
viewportPosition: {
width: 100,
height: 100,
width: 100,
},
},
};
......@@ -36,16 +39,16 @@ describe('window actions', () => {
});
it('should return correct action object with pan=false', () => {
const expectedAction = {
position: {},
type: ActionTypes.FOCUS_WINDOW,
windowId: 'window',
position: {},
};
const mockState = {
companionWindows: {},
windows: {
window: { x: 50, y: 12 },
},
companionWindows: {},
};
const mockDispatch = jest.fn(() => ({}));
......@@ -62,31 +65,37 @@ describe('window actions', () => {
describe('addWindow', () => {
it('should create a new window with merged defaults', () => {
const options = {
id: 'helloworld',
canvasIndex: 1,
id: 'helloworld',
};
const expectedAction = {
companionWindows: [
{
content: 'info',
position: 'left',
},
{
content: 'thumbnail_navigation',
position: 'far-bottom',
},
],
type: ActionTypes.ADD_WINDOW,
window: {
id: 'helloworld',
canvasIndex: 1,
collectionIndex: 0,
height: 400,
id: 'helloworld',
manifestId: null,
maximized: false,
rangeId: null,
x: 260,
y: 300,
sideBarPanel: 'info',
width: 400,
height: 400,
rotation: null,
sideBarPanel: 'info',
view: 'single',
width: 400,
x: 260,
y: 300,
},
companionWindows: [
{ position: 'left', content: 'info' },
{ position: 'far-bottom', content: 'thumbnail_navigation' },
],
};
const mockState = {
......@@ -112,8 +121,8 @@ describe('window actions', () => {
describe('updateWindow', () => {
it('should return correct action object', () => {
const payload = {
foo: 1,
bar: 2,
foo: 1,
};
const action = actions.updateWindow('window-123', payload);
expect(action.type).toBe(ActionTypes.UPDATE_WINDOW);
......@@ -126,16 +135,16 @@ describe('window actions', () => {
it('removes the window and returns windowId', () => {
const id = 'abc123';
const expectedAction = {
companionWindowIds: ['a', 'b', 'c'],
type: ActionTypes.REMOVE_WINDOW,
windowId: id,
companionWindowIds: ['a', 'b', 'c'],
};
const mockState = {
companionWindows: {},
windows: {
abc123: { companionWindowIds: ['a', 'b', 'c'] },
},
companionWindows: {},
};
const mockDispatch = jest.fn(() => ({}));
......@@ -186,9 +195,9 @@ describe('window actions', () => {
it('returns the appropriate action type', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.UPDATE_WINDOW,
id,
payload: { companionAreaOpen: true },
type: ActionTypes.UPDATE_WINDOW,
};
expect(actions.setCompanionAreaOpen(id, true)).toEqual(expectedAction);
});
......@@ -200,9 +209,9 @@ describe('window actions', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.UPDATE_COMPANION_WINDOW,
id,
payload: { position: 'right' },
type: ActionTypes.UPDATE_COMPANION_WINDOW,
};
const mockState = {
......@@ -227,8 +236,8 @@ describe('window actions', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.SET_WINDOW_VIEW_TYPE,
windowId: id,
viewType: 'book',
windowId: id,
};
expect(actions.setWindowViewType(id, 'book')).toEqual(expectedAction);
});
......@@ -239,9 +248,9 @@ describe('window actions', () => {
const windowId = 'abc123';
const panelType = 'panelType';
const expectedAction = {
panelType,
type: ActionTypes.SET_WINDOW_SIDE_BAR_PANEL,
windowId,
panelType,
};
expect(actions.setWindowSideBarPanel(windowId, 'panelType')).toEqual(expectedAction);
});
......@@ -251,22 +260,22 @@ describe('window actions', () => {
it('returns the appropriate action type', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.SET_WINDOW_SIZE,
payload: {
windowId: id,
size: {
height: 200,
width: 200,
x: 20,
y: 20,
width: 200,
height: 200,
},
windowId: id,
},
type: ActionTypes.SET_WINDOW_SIZE,
};
expect(actions.setWindowSize(id, {
height: 200,
width: 200,
x: 20,
y: 20,
width: 200,
height: 200,
})).toEqual(expectedAction);
});
});
......@@ -275,14 +284,14 @@ describe('window actions', () => {
it('returns the appropriate action type', () => {
const id = 'abc123';
const expectedAction = {
type: ActionTypes.UPDATE_WINDOW_POSITION,
payload: {
windowId: id,
position: {
x: 20,
y: 20,
},
windowId: id,
},
type: ActionTypes.UPDATE_WINDOW_POSITION,
};
expect(actions.updateWindowPosition(id, {
x: 20,
......
......@@ -6,16 +6,16 @@ describe('workspace actions', () => {
it('should return correct action type if set to true', () => {
const receivedAction = actions.setWorkspaceFullscreen(true);
const expectedAction = {
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
isFullscreenEnabled: true,
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
};
expect(receivedAction).toEqual(expectedAction);
});
it('should return correct action type if set to false', () => {
const receivedAction = actions.setWorkspaceFullscreen(false);
const expectedAction = {
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
isFullscreenEnabled: false,
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
};
expect(receivedAction).toEqual(expectedAction);
});
......@@ -25,8 +25,8 @@ describe('workspace actions', () => {
const options = { foo: 'bar' };
const expectedAction = {
type: ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT,
layout: { foo: 'bar' },
type: ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT,
};
expect(actions.updateWorkspaceMosaicLayout(options)).toEqual(expectedAction);
});
......@@ -34,8 +34,8 @@ describe('workspace actions', () => {
describe('toggleZoomControls', () => {
it('should set the zoom control visibility', () => {
const expectedAction = {
type: ActionTypes.TOGGLE_ZOOM_CONTROLS,
showZoomControls: true,
type: ActionTypes.TOGGLE_ZOOM_CONTROLS,
};
expect(actions.toggleZoomControls(true)).toEqual(expectedAction);
});
......@@ -43,8 +43,8 @@ describe('workspace actions', () => {
describe('setWorkspaceAddVisibility', () => {
it('should set the workspace add visibility', () => {
const expectedAction = {
type: ActionTypes.SET_WORKSPACE_ADD_VISIBILITY,
isWorkspaceAddVisible: true,
type: ActionTypes.SET_WORKSPACE_ADD_VISIBILITY,
};
expect(actions.setWorkspaceAddVisibility(true)).toEqual(expectedAction);
});
......@@ -52,30 +52,30 @@ describe('workspace actions', () => {
describe('setWorkspaceViewportDimensions', () => {
it('should set the workspace add visibility', () => {
const expectedAction = {
type: ActionTypes.SET_WORKSPACE_VIEWPORT_POSITION,
payload: {
position: {
width: 20,
height: 25,
width: 20,
},
},
type: ActionTypes.SET_WORKSPACE_VIEWPORT_POSITION,
};
expect(actions.setWorkspaceViewportDimensions({
width: 20,
height: 25,
width: 20,
})).toEqual(expectedAction);
});
});
describe('setWorkspaceViewportPosition', () => {
it('should set the workspace add visibility', () => {
const expectedAction = {
type: ActionTypes.SET_WORKSPACE_VIEWPORT_POSITION,
payload: {
position: {
x: 20,
y: 20,
},
},
type: ActionTypes.SET_WORKSPACE_VIEWPORT_POSITION,
};
expect(actions.setWorkspaceViewportPosition({
x: 20,
......
......@@ -59,10 +59,18 @@ describe('CanvasThumbnail', () => {
});
it('can be constrained by maxWidth and maxHeight and a desired aspect ratio', () => {
wrapper = createWrapper({ maxHeight: 400, maxWidth: 500, aspectRatio: 2 });
wrapper = createWrapper({
aspectRatio: 2,
maxHeight: 400,
maxWidth: 500,
});
expect(wrapper.find('img').props().style).toMatchObject({ height: 250, width: 500 });
wrapper = createWrapper({ maxHeight: 400, maxWidth: 500, aspectRatio: 1 });
wrapper = createWrapper({
aspectRatio: 1,
maxHeight: 400,
maxWidth: 500,
});
expect(wrapper.find('img').props().style).toMatchObject({ height: 400, width: 400 });
});
});
......@@ -12,8 +12,14 @@ function createWrapper(props) {
windowId="abc123"
position="right"
companionWindows={[
{ position: 'right', id: 'foo' },
{ position: 'right', id: 'baz' },
{
id: 'foo',
position: 'right',
},
{
id: 'baz',
position: 'right',
},
]}
t={key => key}
{...props}
......@@ -43,7 +49,10 @@ describe('CompanionArea', () => {
const setCompanionAreaOpen = jest.fn();
const wrapper = createWrapper({
position: 'left', sideBarOpen: true, setCompanionAreaOpen, companionAreaOpen: false,
companionAreaOpen: false,
position: 'left',
setCompanionAreaOpen,
sideBarOpen: true,
});
expect(wrapper.find(MiradorMenuButton).length).toBe(1);
......@@ -61,7 +70,10 @@ describe('CompanionArea', () => {
const setCompanionAreaOpen = jest.fn();
const wrapper = createWrapper({
position: 'left', sideBarOpen: true, setCompanionAreaOpen, companionAreaOpen: true,
companionAreaOpen: true,
position: 'left',
setCompanionAreaOpen,
sideBarOpen: true,
});
expect(wrapper.find(MiradorMenuButton).length).toBe(1);
......@@ -77,7 +89,10 @@ describe('CompanionArea', () => {
it('does not show a toggle if the sidebar is collapsed', () => {
const wrapper = createWrapper({
position: 'left', sideBarOpen: false, setCompanionAreaOpen: () => {}, companionAreaOpen: true,
companionAreaOpen: true,
position: 'left',
setCompanionAreaOpen: () => {},
sideBarOpen: false,
});
expect(wrapper.find(MiradorMenuButton).length).toBe(0);
......@@ -85,7 +100,10 @@ describe('CompanionArea', () => {
it('does not show a toggle in other positions', () => {
const wrapper = createWrapper({
position: 'whatever', sideBarOpen: true, setCompanionAreaOpen: () => {}, companionAreaOpen: true,
companionAreaOpen: true,
position: 'whatever',
setCompanionAreaOpen: () => {},
sideBarOpen: true,
});
expect(wrapper.find(MiradorMenuButton).length).toBe(0);
......
......@@ -24,8 +24,8 @@ describe('CompanionWindow', () => {
it('passes the the updateCompanionWindow prop to MiradorMenuButton with the appropriate args', () => {
const updateCompanionWindow = jest.fn();
companionWindow = createWrapper({
updateCompanionWindow,
position: 'left',
updateCompanionWindow,
});
const button = companionWindow.find(MiradorMenuButton);
......@@ -50,7 +50,10 @@ describe('CompanionWindow', () => {
describe('when the companion window is on the right', () => {
const updateCompanionWindow = jest.fn();
companionWindow = createWrapper({ updateCompanionWindow, position: 'right' });
companionWindow = createWrapper({
position: 'right',
updateCompanionWindow,
});
expect(companionWindow.find('WithStyles(Paper).vertical').length).toBe(1);
......@@ -62,7 +65,10 @@ describe('CompanionWindow', () => {
describe('when the companion window is on the bottom', () => {
const updateCompanionWindow = jest.fn();
companionWindow = createWrapper({ updateCompanionWindow, position: 'bottom' });
companionWindow = createWrapper({
position: 'bottom',
updateCompanionWindow,
});
expect(companionWindow.find('WithStyles(Paper).horizontal').length).toBe(1);
......
......@@ -8,8 +8,11 @@ import { GalleryView } from '../../../src/components/GalleryView';
function createWrapper(props) {
return shallow(
<GalleryView
window={{ id: '1234', canvasIndex: 0 }}
canvases={manifesto.create(manifestJson).getSequences()[0].getCanvases()}
window={{
canvasIndex: 0,
id: '1234',
}}
setCanvas={() => {}}
{...props}
/>,
......
......@@ -18,8 +18,16 @@ function createWrapper(props) {
describe('LanguageSettings', () => {
let wrapper;
const languages = [
{ locale: 'de', label: 'Deutsch', current: true },
{ locale: 'en', label: 'English', current: false },
{
current: true,
label: 'Deutsch',
locale: 'de',
},
{
current: false,
label: 'English',
locale: 'en',
},
];
......@@ -74,7 +82,10 @@ describe('LanguageSettings', () => {
it('triggers the handleClick prop when clicking a list item', () => {
const mockHandleClick = jest.fn();
wrapper = createWrapper({ languages, handleClick: mockHandleClick });
wrapper = createWrapper({
handleClick: mockHandleClick,
languages,
});
wrapper.find('WithStyles(MenuItem)').last().simulate('click');
......
......@@ -20,7 +20,15 @@ describe('OpenSeadragonViewer', () => {
wrapper = shallow(
<OpenSeadragonViewer
tileSources={[{ '@id': 'http://foo', width: 100, height: 200 }, { '@id': 'http://bar', width: 150, height: 201 }]}
tileSources={[{
'@id': 'http://foo',
height: 200,
width: 100,
}, {
'@id': 'http://bar',
height: 201,
width: 150,
}]}
windowId="base"
config={{}}
updateViewport={updateViewport}
......@@ -109,9 +117,9 @@ describe('OpenSeadragonViewer', () => {
wrapper.instance().ref = { current: true };
OpenSeadragon.mockImplementation(() => ({
viewport: { panTo, zoomTo },
addHandler,
addTiledImage: jest.fn().mockResolvedValue('event'),
viewport: { panTo, zoomTo },
}));
});
......@@ -150,8 +158,8 @@ describe('OpenSeadragonViewer', () => {
viewport: {
centerSpringX: { target: { value: 10 } },
centerSpringY: { target: { value: 10 } },
zoomSpring: { target: { value: 1 } },
panTo,
zoomSpring: { target: { value: 1 } },
zoomTo,
},
};
......@@ -175,9 +183,9 @@ describe('OpenSeadragonViewer', () => {
const forceRedraw = jest.fn();
wrapper.instance().osdCanvasOverlay = {
canvasUpdate,
clear,
resize,
canvasUpdate,
};
wrapper.instance().viewer = { forceRedraw };
......
......@@ -15,8 +15,8 @@ function createWrapper(props) {
}
classes={{}}
window={{
id: 'foobar',
canvasIndex: 1,
id: 'foobar',
}}
config={{ thumbnailNavigation: { height: 150, width: 100 } }}
position="far-bottom"
......@@ -78,8 +78,8 @@ describe('ThumbnailNavigation', () => {
});
it('renders containers based off of canvas groupings ', () => {
wrapper = createWrapper({
setCanvas,
canvasGroupings: new CanvasGroupings(manifesto.create(manifestJson).getSequences()[0].getCanvases(), 'book'),
setCanvas,
});
grid = wrapper.find('AutoSizer')
.dive()
......@@ -94,8 +94,8 @@ describe('ThumbnailNavigation', () => {
wrapper.instance().gridRef = { current: { recomputeGridSize: mockRecompute } };
wrapper.setProps({
window: {
id: 'foobar',
canvasIndex: 1,
id: 'foobar',
thumbnailNavigationPosition: 'bottom',
view: 'book',
},
......@@ -104,7 +104,10 @@ describe('ThumbnailNavigation', () => {
});
describe('calculating instance methods', () => {
beforeEach(() => {
rightWrapper = createWrapper({ setCanvas, position: 'far-right' });
rightWrapper = createWrapper({
position: 'far-right',
setCanvas,
});
});
it('style', () => {
expect(wrapper.instance().style()).toMatchObject({ height: '150px', width: '100%' });
......@@ -116,8 +119,8 @@ describe('ThumbnailNavigation', () => {
wrapper.instance().gridRef = { current: { recomputeGridSize: mockRecompute } };
wrapper.setProps({
window: {
id: 'foobar',
canvasIndex: 1,
id: 'foobar',
thumbnailNavigationPosition: 'bottom',
view: 'book',
},
......
......@@ -22,7 +22,10 @@ describe('ViewerNavigation', () => {
setCanvas = jest.fn();
wrapper = createWrapper({
setCanvas,
window: { id: 'foo', canvasIndex: 0 },
window: {
canvasIndex: 0,
id: 'foo',
},
});
});
it('renders the component', () => {
......@@ -41,7 +44,10 @@ describe('ViewerNavigation', () => {
describe('when next canvases are not present', () => {
it('nextCanvas button is disabled', () => {
const endWrapper = createWrapper({
window: { id: 'foo', canvasIndex: 1 },
window: {
canvasIndex: 1,
id: 'foo',
},
});
expect(endWrapper.find('.mirador-next-canvas-button').prop('disabled')).toBe(true);
});
......@@ -60,7 +66,11 @@ describe('ViewerNavigation', () => {
wrapper = createWrapper({
canvases: [1, 2, 3],
setCanvas,
window: { id: 'foo', canvasIndex: 0, view: 'book' },
window: {
canvasIndex: 0,
id: 'foo',
view: 'book',
},
});
wrapper.find('.mirador-next-canvas-button').simulate('click');
expect(setCanvas).toHaveBeenCalledWith('foo', 2);
......@@ -68,7 +78,11 @@ describe('ViewerNavigation', () => {
it('setCanvas function is called after click for previous', () => {
wrapper = createWrapper({
setCanvas,
window: { id: 'foo', canvasIndex: 5, view: 'book' },
window: {
canvasIndex: 5,
id: 'foo',
view: 'book',
},
});
wrapper.find('.mirador-previous-canvas-button').simulate('click');
expect(wrapper.find('.mirador-previous-canvas-button').prop('aria-label')).toBe('previousCanvas');
......
......@@ -20,12 +20,12 @@ function createWrapper(props, context) {
describe('Window', () => {
let wrapper;
const window = {
height: 400,
id: 123,
maximized: false,
width: 400,
x: 2700,
y: 2700,
width: 400,
height: 400,
maximized: false,
};
it('should render nothing, if provided with no window data', () => {
wrapper = shallow(<Window t={k => k} />);
......
......@@ -89,8 +89,8 @@ describe('WindowList', () => {
describe('with multiple windows', () => {
beforeEach(() => {
windows = {
zyx: { id: 'zyx', manifestId: '123' },
xyz: { id: 'xyz', manifestId: 'abc' },
zyx: { id: 'zyx', manifestId: '123' },
};
titles = { xyz: 'Some title' };
......
......@@ -35,8 +35,14 @@ describe('WindowSideBarAnnotationsPanel', () => {
it('renders a list with a list item for each annotation', () => {
wrapper = createWrapper({
annotations: [
{ id: 'abc123', content: 'First Annotation' },
{ id: 'xyz321', content: 'Last Annotation' },
{
content: 'First Annotation',
id: 'abc123',
},
{
content: 'Last Annotation',
id: 'xyz321',
},
],
});
......@@ -50,8 +56,16 @@ describe('WindowSideBarAnnotationsPanel', () => {
wrapper = createWrapper({
annotations: [
{ id: 'abc123', targetId: 'example.com/iiif/12345', content: 'First Annotation' },
{ id: 'xyz321', targetId: 'example.com/iiif/54321', content: 'Last Annotation' },
{
content: 'First Annotation',
id: 'abc123',
targetId: 'example.com/iiif/12345',
},
{
content: 'Last Annotation',
id: 'xyz321',
targetId: 'example.com/iiif/54321',
},
],
selectAnnotation,
});
......@@ -64,12 +78,20 @@ describe('WindowSideBarAnnotationsPanel', () => {
const deselectAnnotation = jest.fn();
wrapper = createWrapper({
selectedAnnotationIds: ['abc123'],
annotations: [
{ id: 'abc123', targetId: 'example.com/iiif/12345', content: 'First Annotation' },
{ id: 'xyz321', targetId: 'example.com/iiif/54321', content: 'Last Annotation' },
{
content: 'First Annotation',
id: 'abc123',
targetId: 'example.com/iiif/12345',
},
{
content: 'Last Annotation',
id: 'xyz321',
targetId: 'example.com/iiif/54321',
},
],
deselectAnnotation,
selectedAnnotationIds: ['abc123'],
});
wrapper.find('WithStyles(ListItem)').first().simulate('click');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment