diff --git a/__tests__/integration/mirador/invalid-api-response.test.js b/__tests__/integration/mirador/invalid-api-response.test.js index 3bc9a2d414fbedc9be8d3ac18c4a56c1f41f1f5c..d0edd9de16a0702f5c1f3c14ad784f12079a09d4 100644 --- a/__tests__/integration/mirador/invalid-api-response.test.js +++ b/__tests__/integration/mirador/invalid-api-response.test.js @@ -25,12 +25,8 @@ describe('Mirador Invalid API Response Handler Test', () => { it('renders an error message when a manifest cannot be loaded (and allows it to be dismissed)', async () => { await fetchManifest('http://127.0.0.1:4488/__tests__/fixtures/version-2/broken'); - await expect(page).toMatchElement( - 'p', { text: 'The resource cannot be added:', timeout: 2000 }, - ); - await expect(page).toMatchElement( - 'p', { text: 'http://127.0.0.1:4488/__tests__/fixtures/version-2/broken' }, - ); + await expect(page).toMatchElement('p', { text: 'The resource cannot be added:', timeout: 2000 }); + await expect(page).toMatchElement('p', { text: 'http://127.0.0.1:4488/__tests__/fixtures/version-2/broken' }); await expect(page).toClick('button', { text: 'Dismiss' }); diff --git a/__tests__/src/components/OpenSeadragonViewer.test.js b/__tests__/src/components/OpenSeadragonViewer.test.js index 29566d2e677838560fc16a23c950c203d8e4bafa..1c957824c3ece5fbe987c8146b10bd258d1f0b2b 100644 --- a/__tests__/src/components/OpenSeadragonViewer.test.js +++ b/__tests__/src/components/OpenSeadragonViewer.test.js @@ -270,12 +270,8 @@ describe('OpenSeadragonViewer', () => { it('calls the OSD viewport panTo and zoomTo with the component state', () => { wrapper.instance().componentDidMount(); - expect(panTo).toHaveBeenCalledWith( - { x: 1, y: 0, zoom: 0.5 }, true, - ); - expect(zoomTo).toHaveBeenCalledWith( - 0.5, { x: 1, y: 0, zoom: 0.5 }, true, - ); + expect(panTo).toHaveBeenCalledWith({ x: 1, y: 0, zoom: 0.5 }, true); + expect(zoomTo).toHaveBeenCalledWith(0.5, { x: 1, y: 0, zoom: 0.5 }, true); }); it('adds animation-start/finish flag for rerendering performance', () => { @@ -330,12 +326,8 @@ describe('OpenSeadragonViewer', () => { }, }); - expect(panTo).toHaveBeenCalledWith( - expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false, - ); - expect(zoomTo).toHaveBeenCalledWith( - 0.5, expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false, - ); + expect(panTo).toHaveBeenCalledWith(expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false); + expect(zoomTo).toHaveBeenCalledWith(0.5, expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false); expect(setRotation).toHaveBeenCalledWith(90); expect(setFlip).toHaveBeenCalledWith(true); expect(forceRedraw).not.toHaveBeenCalled(); diff --git a/__tests__/src/components/SearchPanelControls.test.js b/__tests__/src/components/SearchPanelControls.test.js index d09f641230cbb66e5cc7dcec22eaa22c2e3710db..64c57780ca19c57ccfa76ff0b03ff1aa340eca34 100644 --- a/__tests__/src/components/SearchPanelControls.test.js +++ b/__tests__/src/components/SearchPanelControls.test.js @@ -36,9 +36,7 @@ describe('SearchPanelControls', () => { const value = 'somestring'; wrapper.find(Autocomplete).prop('onChange')({}, { match: value }, {}); expect(wrapper.state().search).toEqual(value); - expect(fetchSearch).toHaveBeenCalledWith( - 'window', 'cw', 'http://example.com/search?q=somestring', 'somestring', - ); + expect(fetchSearch).toHaveBeenCalledWith('window', 'cw', 'http://example.com/search?q=somestring', 'somestring'); }); it('renders a text input through the renderInput prop', () => { const wrapper = createWrapper(); diff --git a/__tests__/src/components/Window.test.js b/__tests__/src/components/Window.test.js index c16b361fef230d10765295efaccef0786e4ec971..78bd9f3884e3690e29f85f8d67361bb369e4ffec 100644 --- a/__tests__/src/components/Window.test.js +++ b/__tests__/src/components/Window.test.js @@ -47,18 +47,14 @@ describe('Window', () => { describe('when workspaceType is mosaic', () => { xit('calls the context mosaicWindowActions connectDragSource method to make WindowTopBar draggable', () => { const connectDragSource = jest.fn(component => component); - wrapper = createWrapper( - { windowDraggable: true, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }, - ); + wrapper = createWrapper({ windowDraggable: true, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }); expect(wrapper.find(WindowTopBar)).toHaveLength(1); expect(connectDragSource).toHaveBeenCalled(); }); it('does not call the context mosaicWindowActions connectDragSource when the windowDraggable is set to false', () => { const connectDragSource = jest.fn(component => component); - wrapper = createWrapper( - { windowDraggable: false, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }, - ); + wrapper = createWrapper({ windowDraggable: false, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }); expect(wrapper.find(WindowTopBar)).toHaveLength(1); expect(connectDragSource).not.toHaveBeenCalled(); }); diff --git a/__tests__/src/sagas/windows.test.js b/__tests__/src/sagas/windows.test.js index 796c0adc0072fecef6b2290c6bdd649232d08d32..126a381625da55b0e2e9bef4e38053f7c8ceb908 100644 --- a/__tests__/src/sagas/windows.test.js +++ b/__tests__/src/sagas/windows.test.js @@ -218,8 +218,10 @@ describe('window-level sagas', () => { return expectSaga(setCurrentAnnotationsOnCurrentCanvas, action) .provide([ - [select(getSearchForWindow, - { windowId: 'abc123' }), {}], + [select( + getSearchForWindow, + { windowId: 'abc123' }, + ), {}], ]) .run() .then(({ allEffects }) => allEffects.length === 0); @@ -234,8 +236,10 @@ describe('window-level sagas', () => { return expectSaga(setCurrentAnnotationsOnCurrentCanvas, action) .provide([ - [select(getSearchForWindow, - { windowId: 'abc123' }), { cwid: { } }], + [select( + getSearchForWindow, + { windowId: 'abc123' }, + ), { cwid: { } }], [select(getAnnotationsBySearch, { canvasIds: ['a', 'b'], companionWindowIds: ['cwid'], windowId: 'abc123' }), { }], ]) @@ -256,8 +260,10 @@ describe('window-level sagas', () => { return expectSaga(setCurrentAnnotationsOnCurrentCanvas, action) .provide([ - [select(getSearchForWindow, - { windowId: 'abc123' }), { cwid: { } }], + [select( + getSearchForWindow, + { windowId: 'abc123' }, + ), { cwid: { } }], [select(getAnnotationsBySearch, { canvasIds: ['a', 'b'], companionWindowIds: ['cwid'], windowId: 'abc123' }), { cwid: ['annoId'] }], ]) diff --git a/__tests__/src/selectors/canvases.test.js b/__tests__/src/selectors/canvases.test.js index e8fc9adb8ce1f84de636ddfc70c2b75d7896de70..43d1a0f735df6545bf35ed622274b99498ea1483 100644 --- a/__tests__/src/selectors/canvases.test.js +++ b/__tests__/src/selectors/canvases.test.js @@ -355,9 +355,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasNonTiledResources( - state, { windowId: 'a' }, - )[0].id).toBe('http://iiif.io/api/presentation/2.0/example/fixtures/resources/page1-full.png'); + expect(getVisibleCanvasNonTiledResources(state, { windowId: 'a' })[0].id).toBe('http://iiif.io/api/presentation/2.0/example/fixtures/resources/page1-full.png'); }); it('works for v3 Presentation API', () => { const state = { @@ -376,9 +374,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasNonTiledResources( - state, { windowId: 'a' }, - )[0].id).toBe('http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png'); + expect(getVisibleCanvasNonTiledResources(state, { windowId: 'a' })[0].id).toBe('http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png'); }); describe('getVisibleCanvasVideoResources', () => { @@ -399,9 +395,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasVideoResources( - state, { windowId: 'a' }, - )[0].id).toBe('https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4'); + expect(getVisibleCanvasVideoResources(state, { windowId: 'a' })[0].id).toBe('https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4'); }); }); @@ -423,9 +417,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasCaptions( - state, { windowId: 'a' }, - )[0].id).toBe('https://example.com/file.vtt'); + expect(getVisibleCanvasCaptions(state, { windowId: 'a' })[0].id).toBe('https://example.com/file.vtt'); }); }); @@ -447,9 +439,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasAudioResources( - state, { windowId: 'a' }, - )[0].id).toBe('https://fixtures.iiif.io/audio/indiana/mahler-symphony-3/CD1/medium/128Kbps.mp4'); + expect(getVisibleCanvasAudioResources(state, { windowId: 'a' })[0].id).toBe('https://fixtures.iiif.io/audio/indiana/mahler-symphony-3/CD1/medium/128Kbps.mp4'); }); }); }); diff --git a/__tests__/src/selectors/searches.test.js b/__tests__/src/selectors/searches.test.js index 3a9e3791a4e3e215d79cb17419d0785c21ea6a0e..378417caf92aed1c363bb59fe3bbc8365891669f 100644 --- a/__tests__/src/selectors/searches.test.js +++ b/__tests__/src/selectors/searches.test.js @@ -309,9 +309,7 @@ describe('getResourceAnnotationForSearchHit', () => { }; expect( - getResourceAnnotationForSearchHit( - state, { annotationUri: annoId, companionWindowId, windowId: 'a' }, - ).resource['@id'], + getResourceAnnotationForSearchHit(state, { annotationUri: annoId, companionWindowId, windowId: 'a' }).resource['@id'], ).toEqual(annoId); }); }); @@ -344,9 +342,7 @@ describe('getResourceAnnotationLabel', () => { }; expect( - getResourceAnnotationLabel( - state, { annotationUri: annoId, companionWindowId, windowId: 'a' }, - ), + getResourceAnnotationLabel(state, { annotationUri: annoId, companionWindowId, windowId: 'a' }), ).toEqual(['The Annotation Label']); }); @@ -369,9 +365,7 @@ describe('getResourceAnnotationLabel', () => { }; expect( - getResourceAnnotationLabel( - state, { annotationUri: annoId, companionWindowId, windowId: 'a' }, - ), + getResourceAnnotationLabel(state, { annotationUri: annoId, companionWindowId, windowId: 'a' }), ).toEqual([]); }); }); diff --git a/src/components/AnnotationsOverlay.js b/src/components/AnnotationsOverlay.js index eb527f1d9f7a48679fcf88b544166120426bf968..56215888e5e55166056bb0a7f1a1cde67b38dab9 100644 --- a/src/components/AnnotationsOverlay.js +++ b/src/components/AnnotationsOverlay.js @@ -85,12 +85,8 @@ export class AnnotationsOverlay extends Component { this.initializeViewer(); - const annotationsUpdated = !AnnotationsOverlay.annotationsMatch( - annotations, prevProps.annotations, - ); - const searchAnnotationsUpdated = !AnnotationsOverlay.annotationsMatch( - searchAnnotations, prevProps.searchAnnotations, - ); + const annotationsUpdated = !AnnotationsOverlay.annotationsMatch(annotations, prevProps.annotations); + const searchAnnotationsUpdated = !AnnotationsOverlay.annotationsMatch(searchAnnotations, prevProps.searchAnnotations); const hoveredAnnotationsUpdated = ( xor(hoveredAnnotationIds, prevProps.hoveredAnnotationIds).length > 0 diff --git a/src/components/Window.js b/src/components/Window.js index 56d3bd45e6c893b89638f30836c3aaccf1c771ed..30462d2e7ed84326a6f4687e16cb9043c0e9abf2 100644 --- a/src/components/Window.js +++ b/src/components/Window.js @@ -83,8 +83,11 @@ export class Window extends Component { elevation={1} id={windowId} className={ - cn(classes.window, ns('window'), - maximized ? classes.maximized : null) + cn( + classes.window, + ns('window'), + maximized ? classes.maximized : null, + ) } aria-label={t('window', { label })} > diff --git a/src/containers/CanvasAnnotations.js b/src/containers/CanvasAnnotations.js index 7c9caa748aa43713f8f59b1928fbf8c94a959957..5bebeae7885399b8685ac82bab9462b38020add4 100644 --- a/src/containers/CanvasAnnotations.js +++ b/src/containers/CanvasAnnotations.js @@ -28,9 +28,7 @@ function getIdAndContentOfResources(resources) { /** For connect */ const mapStateToProps = (state, { canvasId, windowId }) => ({ annotations: getIdAndContentOfResources( - getAnnotationResourcesByMotivationForCanvas( - state, { canvasId, windowId }, - ), + getAnnotationResourcesByMotivationForCanvas(state, { canvasId, windowId }), ), htmlSanitizationRuleSet: getConfig(state).annotations.htmlSanitizationRuleSet, label: getCanvasLabel(state, { diff --git a/src/containers/SearchHit.js b/src/containers/SearchHit.js index 9c535f5d59163da10d05a58d5ddeceeb2ed47ca0..c1da963977a805c33b72c8fb991702120ade2f32 100644 --- a/src/containers/SearchHit.js +++ b/src/containers/SearchHit.js @@ -23,12 +23,8 @@ const mapStateToProps = (state, { annotationId, hit = { annotations: [] }, companionWindowId, windowId, }) => { const realAnnoId = annotationId || hit.annotations[0]; - const hitAnnotation = getResourceAnnotationForSearchHit( - state, { annotationUri: realAnnoId, companionWindowId, windowId }, - ); - const annotationLabel = getResourceAnnotationLabel( - state, { annotationUri: realAnnoId, companionWindowId, windowId }, - ); + const hitAnnotation = getResourceAnnotationForSearchHit(state, { annotationUri: realAnnoId, companionWindowId, windowId }); + const annotationLabel = getResourceAnnotationLabel(state, { annotationUri: realAnnoId, companionWindowId, windowId }); const selectedCanvasIds = getVisibleCanvasIds(state, { windowId }); const selectedContentSearchAnnotationsIds = getSelectedContentSearchAnnotationIds(state, { diff --git a/src/containers/WindowAuthenticationBar.js b/src/containers/WindowAuthenticationBar.js index 3b42a93aa7f44067e0cdc09958a20a90c4059b66..f3b7f8733367a8b7f2adf4c1e35f74d49b3353f1 100644 --- a/src/containers/WindowAuthenticationBar.js +++ b/src/containers/WindowAuthenticationBar.js @@ -13,9 +13,7 @@ import { WindowAuthenticationBar } from '../components/WindowAuthenticationBar'; const styles = theme => ({ buttonInvert: { '&:hover': { - backgroundColor: alpha( - theme.palette.secondary.contrastText, 1 - theme.palette.action.hoverOpacity, - ), + backgroundColor: alpha(theme.palette.secondary.contrastText, 1 - theme.palette.action.hoverOpacity), }, backgroundColor: theme.palette.secondary.contrastText, marginLeft: theme.spacing(5), diff --git a/src/lib/ThumbnailFactory.js b/src/lib/ThumbnailFactory.js index 79c063f8852c82b9044640ed28e33d25b8e6de3d..988a422b0c92a18973ab900ec55cf2bad78c551f 100644 --- a/src/lib/ThumbnailFactory.js +++ b/src/lib/ThumbnailFactory.js @@ -90,27 +90,23 @@ class ThumbnailFactory { const imageFitness = (test) => test.width * test.height - targetArea; /** Look for the size that's just bigger than we prefer... */ - closestSize = sizes.reduce( - (best, test) => { - const score = imageFitness(test); + closestSize = sizes.reduce((best, test) => { + const score = imageFitness(test); - if (score < 0) return best; + if (score < 0) return best; - return Math.abs(score) < Math.abs(imageFitness(best)) - ? test - : best; - }, closestSize, - ); + return Math.abs(score) < Math.abs(imageFitness(best)) + ? test + : best; + }, closestSize); /** .... but not "too" big; we'd rather scale up an image than download too much */ if (closestSize.width * closestSize.height > targetArea * 6) { - closestSize = sizes.reduce( - (best, test) => ( - Math.abs(imageFitness(test)) < Math.abs(imageFitness(best)) - ? test - : best - ), closestSize, - ); + closestSize = sizes.reduce((best, test) => ( + Math.abs(imageFitness(test)) < Math.abs(imageFitness(best)) + ? test + : best + ), closestSize); } if (closestSize.default) return undefined; diff --git a/src/lib/TruncatedHit.js b/src/lib/TruncatedHit.js index f6363cf3abe12678b45649e6c33db396fe1aa568..8317b098434cdb82146e2626a5bef2746bf458de 100644 --- a/src/lib/TruncatedHit.js +++ b/src/lib/TruncatedHit.js @@ -25,16 +25,12 @@ export default class TruncatedHit { /** */ get before() { if (!this.hit.before) return ''; - return this.hit.before.substring( - this.hit.before.length - this.charsOnSide, this.hit.before.length, - ); + return this.hit.before.substring(this.hit.before.length - this.charsOnSide, this.hit.before.length); } /** */ get after() { if (!this.hit.after) return ''; - return this.hit.after.substring( - 0, Math.min(this.hit.after.length, this.charsOnSide), - ); + return this.hit.after.substring(0, Math.min(this.hit.after.length, this.charsOnSide)); } } diff --git a/src/state/createStore.js b/src/state/createStore.js index 717b0b8915cc9dd00df4b0652a56a4d291b80c65..9467f322c5535aab6d73abcd48d0aaed5b3dc9a1 100644 --- a/src/state/createStore.js +++ b/src/state/createStore.js @@ -27,9 +27,7 @@ function configureStore(pluginReducers, pluginSagas = []) { const store = createStore( rootReducer, composeWithDevTools( - applyMiddleware( - thunkMiddleware, sagaMiddleware, - ), + applyMiddleware(thunkMiddleware, sagaMiddleware), ), ); diff --git a/src/state/sagas/iiif.js b/src/state/sagas/iiif.js index 41823156bc7b8ac6b423ec9dafe4e8efdb019e53..bf34810fd9f1aaf70102277594a5841467521040 100644 --- a/src/state/sagas/iiif.js +++ b/src/state/sagas/iiif.js @@ -63,9 +63,7 @@ function* fetchIiifResourceWithAuth(url, iiifResource, options, { degraded, fail } } - const { error, json, response } = yield call( - fetchIiifResource, url, urlOptions, { failure: arg => arg, success: arg => arg }, - ); + const { error, json, response } = yield call(fetchIiifResource, url, urlOptions, { failure: arg => arg, success: arg => arg }); // Hard error either requesting the resource or deserializing the JSON. if (error) { diff --git a/src/state/sagas/windows.js b/src/state/sagas/windows.js index bc63cdcbb9a072fbdb5f4dd4dd23890d92974823..ca256b1bc25db1c75e9db72f85e3299a5be42a1d 100644 --- a/src/state/sagas/windows.js +++ b/src/state/sagas/windows.js @@ -94,9 +94,7 @@ export function* setWindowStartingCanvas(action) { const windowId = action.id || action.window.id; if (canvasId) { - const thunk = yield call( - setCanvas, windowId, canvasId, null, { preserveViewport: !!action.payload }, - ); + const thunk = yield call(setCanvas, windowId, canvasId, null, { preserveViewport: !!action.payload }); yield put(thunk); } else { const manifestoInstance = yield select(getManifestoInstance, { manifestId }); @@ -156,9 +154,7 @@ export function* setCurrentAnnotationsOnCurrentCanvas({ const companionWindowIds = Object.keys(searches || {}); if (companionWindowIds.length === 0) return; - const annotationBySearch = yield select( - getAnnotationsBySearch, { canvasIds: visibleCanvases, companionWindowIds, windowId }, - ); + const annotationBySearch = yield select(getAnnotationsBySearch, { canvasIds: visibleCanvases, companionWindowIds, windowId }); yield all( Object.keys(annotationBySearch) @@ -213,9 +209,7 @@ export function* setCanvasOfFirstSearchResult({ companionWindowId, windowId }) { if (selectedIds.length !== 0) return; - const annotations = yield select( - getSortedSearchAnnotationsForCompanionWindow, { companionWindowId, windowId }, - ); + const annotations = yield select(getSortedSearchAnnotationsForCompanionWindow, { companionWindowId, windowId }); if (!annotations || annotations.length === 0) return; yield put(selectAnnotation(windowId, annotations[0].id)); diff --git a/src/state/selectors/searches.js b/src/state/selectors/searches.js index 3e541084e325e3ca41cd962cf119dc91cf15af3a..00656169c8bfb5ed4c110e1434aa02a034ee8b4f 100644 --- a/src/state/selectors/searches.js +++ b/src/state/selectors/searches.js @@ -108,9 +108,7 @@ export const getSortedSearchHitsForCompanionWindow = createSelector( [ getSearchHitsForCompanionWindow, getCanvases, - (state, { companionWindowId, windowId }) => annotationUri => getResourceAnnotationForSearchHit( - state, { annotationUri, companionWindowId, windowId }, - ), + (state, { companionWindowId, windowId }) => annotationUri => getResourceAnnotationForSearchHit(state, { annotationUri, companionWindowId, windowId }), ], (searchHits, canvases, annotationForSearchHit) => { if (!canvases || canvases.length === 0) return []; @@ -229,9 +227,7 @@ const getAnnotationById = createSelector( export const getCanvasForAnnotation = createSelector( [ getAnnotationById, - (state, { windowId }) => canvasId => getCanvas( - state, { canvasId, windowId }, - ), + (state, { windowId }) => canvasId => getCanvas(state, { canvasId, windowId }), ], (annotation, getCanvasById) => { const canvasId = annotation && annotation.targetId;