diff --git a/__tests__/fixtures/version-2/2017498721.json b/__tests__/fixtures/version-2/2017498721.json new file mode 100644 index 0000000000000000000000000000000000000000..2718d7b76aee117c804b65762f1e9a9553e07fb6 --- /dev/null +++ b/__tests__/fixtures/version-2/2017498721.json @@ -0,0 +1,82 @@ +{ + "@context" : "http://iiif.io/api/presentation/2/context.json", + "@id" : "https://www.loc.gov/item/2017498721/manifest.json", + "viewingHint" : "paged", + "metadata" : [ + { + "label" : "APA Citation Style", + "value" : "Ṣalāḥ Al-Dīn Bak, M. & Eltaher Collection. (1949) <cite>1. al-Jāmiʻah al-ʻArabīyah wa-aḥdāth Filasṭīn ; 2. al-Qaḍīyah al-Filasṭīnīyah amāma Lajnat al-tawfīq</cite>. [Cairo?: Maṭbaʻat Fāḍil] [Pdf] Retrieved from the Library of Congress, https://www.loc.gov/item/2017498721/." + }, + { + "label" : "MLA Citation Style", + "value" : "Ṣalāḥ Al-Dīn Bak, Muḥammad, Author, and Eltaher Collection. <cite>1. al-Jāmiʻah al-ʻArabīyah wa-aḥdāth Filasṭīn ; 2. al-Qaḍīyah al-Filasṭīnīyah amāma Lajnat al-tawfīq</cite>. [Cairo?: Maṭbaʻat Fāḍil, 1949] Pdf. Retrieved from the Library of Congress, <www.loc.gov/item/2017498721/>." + }, + { + "label" : "Chicago Citation Style", + "value" : "Ṣalāḥ Al-Dīn Bak, Muḥammad, Author, and Eltaher Collection. <cite>1. al-Jāmiʻah al-ʻArabīyah wa-aḥdāth Filasṭīn ; 2. al-Qaḍīyah al-Filasṭīnīyah amāma Lajnat al-tawfīq</cite>. [Cairo?: Maṭbaʻat Fāḍil, 1949] Pdf. https://www.loc.gov/item/2017498721/." + }, + { + "label" : "Contributors", + "value" : [ + "Ṣalāḥ al-Dīn Bak, Muḥammad, author.", + "Eltaher Collection (Library of Congress)" + ] + }, + { + "label" : "Created Published", + "value" : [ + "[Cairo?] : Maṭbaʻat Fāḍil, [1949]" + ] + }, + { + "value" : [ + "book" + ], + "label" : "Original Format" + }, + { + "value" : [ + "palestine", + "politics and government", + "arab-israeli conflict", + "sources" + ], + "label" : "Subjects" + }, + { + "value" : [ + "image", + "pdf" + ], + "label" : "Online Format" + }, + { + "label" : "Item Url", + "value" : "https://www.loc.gov/item/2017498721/" + } + ], + "logo" : "https://loc.gov/static/images/logo-loc-new-branding.svg", + "seeAlso" : [ + { + "@id" : "https://lccn.loc.gov/2017498721/marcxml", + "format" : "text/xml" + }, + { + "@id" : "https://lccn.loc.gov/2017498721/mods", + "format" : "text/xml" + }, + { + "format" : "text/html", + "@id" : "https://lccn.loc.gov/2017498721/dc" + } + ], + "navDate" : "1949-01-01:T00:00:00Z", + "attribution" : "Provided by the Library of Congress", + "viewingDirection" : "left-to-right", + "description" : "In Arabic.", + "thumbnail" : { + "@id" : "https://cdn.loc.gov/service/amed/amedeltaher/2017498721/2017498721.gif" + }, + "label" : "1. al-Jāmiʻah al-ʻArabīyah wa-aḥdāth Filasṭīn ; 2. al-Qaḍīyah al-Filasṭīnīyah amāma Lajnat al-tawfīq", + "@type" : "sc:Manifest" +} diff --git a/__tests__/src/selectors/manifests.test.js b/__tests__/src/selectors/manifests.test.js index d94344acc7b680eb7fe05c5daa5149a920531b2f..a27bc2fd8a3dd538e21d60d1ff8deee219834238 100644 --- a/__tests__/src/selectors/manifests.test.js +++ b/__tests__/src/selectors/manifests.test.js @@ -7,6 +7,7 @@ import manifestFixtureSn904cj3429 from '../../fixtures/version-2/sn904cj3429.jso import manifestFixturev3001 from '../../fixtures/version-3/001.json'; import manifestFixtureWithAProvider from '../../fixtures/version-3/with_a_provider.json'; import manifestFixtureFg165hz3589 from '../../fixtures/version-2/fg165hz3589.json'; +import manifestFixture2017498721 from '../../fixtures/version-2/2017498721.json'; import { getManifestoInstance, getManifestLocale, @@ -487,6 +488,11 @@ describe('getManifestViewingHint', () => { expect(getManifestViewingHint(state, { manifestId: 'x' })).toEqual('individuals'); }); + it('gets from the manifest if this is no sequence', () => { + const state = { manifests: { x: { json: manifestFixture2017498721 } } }; + expect(getManifestViewingHint(state, { manifestId: 'x' })).toEqual('paged'); + }); + it('gets from the sequence', () => { const state = { manifests: { x: { json: manifestFixture015 } } }; expect(getManifestViewingHint(state, { manifestId: 'x' })).toEqual('paged'); diff --git a/src/state/selectors/manifests.js b/src/state/selectors/manifests.js index 7b8cd353ef174a79983ec1d024e6c19280163f7a..8e45104ffe0e246cf36ded4cbd838e8e7495d86a 100644 --- a/src/state/selectors/manifests.js +++ b/src/state/selectors/manifests.js @@ -410,7 +410,8 @@ export const getManifestViewingHint = createSelector( [getManifestoInstance], (manifest) => { if (!manifest) return null; - const viewingHint = manifest.getSequences()[0].getViewingHint() || manifest.getViewingHint(); + const viewingHint = (manifest.getSequences()[0] && manifest.getSequences()[0].getViewingHint()) + || manifest.getViewingHint(); if (viewingHint) return viewingHint.value; return null; },