diff --git a/packages/iiif-redux/__tests__/api/2.x/annotation-list/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/annotation-list/descriptive-test.js index 2b16e95e..28df0f63 100644 --- a/packages/iiif-redux/__tests__/api/2.x/annotation-list/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/annotation-list/descriptive-test.js @@ -156,9 +156,9 @@ describe('api/2.x/annotationList/descriptive', () => { describe('getLogo', () => { it('should load logo from annotationList', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/annotation/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/annotation/descriptive-test.js index 4f846149..a32235a4 100644 --- a/packages/iiif-redux/__tests__/api/2.x/annotation/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/annotation/descriptive-test.js @@ -156,9 +156,9 @@ describe('api/2.x/annotation/descriptive', () => { describe('getLogo', () => { it('should load logo from annotation', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/canvas/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/canvas/descriptive-test.js index d698ab45..cc43a17e 100644 --- a/packages/iiif-redux/__tests__/api/2.x/canvas/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/canvas/descriptive-test.js @@ -93,9 +93,9 @@ describe('api/2.x/canvas/descriptive', () => { describe('getLogo', () => { it('should load logo from canvas', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/collection/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/collection/descriptive-test.js index 5cfba895..d4a1d82e 100644 --- a/packages/iiif-redux/__tests__/api/2.x/collection/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/collection/descriptive-test.js @@ -98,9 +98,9 @@ describe('api/2.x/collection/descriptive', () => { describe('getLogo', () => { it('should load logo from collection', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/external-resource/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/external-resource/descriptive-test.js index 9d597a02..9d664511 100644 --- a/packages/iiif-redux/__tests__/api/2.x/external-resource/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/external-resource/descriptive-test.js @@ -157,9 +157,9 @@ describe('api/2.x/external-resource/descriptive', () => { describe('getLogo', () => { it('should load logo from externalResource', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/iiif/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/iiif/descriptive-test.js index 2eb1ff7b..3bdbf274 100644 --- a/packages/iiif-redux/__tests__/api/2.x/iiif/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/iiif/descriptive-test.js @@ -104,7 +104,7 @@ describe('api/iiif/descriptive', () => { describe('getLogo', () => { it('should ignore missing logos', () => { - expect(getLogo({})).toEqual(null); + expect(getLogo({})).toEqual([]); }); it('should unwrap service to ID', () => { expect( @@ -118,14 +118,23 @@ describe('api/iiif/descriptive', () => { }, }, }) - ).toEqual('http://example.org/logos/institution1.jpg'); + ).toEqual([ + { + '@id': 'http://example.org/logos/institution1.jpg', + service: { + '@context': 'http://iiif.io/api/image/2/context.json', + '@id': 'http://example.org/service/inst1', + profile: 'http://iiif.io/api/image/2/level2.json', + }, + }, + ]); expect( getLogo({ logo: 'http://example.org/logos/institution1.jpg', }) - ).toEqual('http://example.org/logos/institution1.jpg'); + ).toEqual(['http://example.org/logos/institution1.jpg']); }); - it('should return the first service', () => { + it('should return all images', () => { expect( getLogo({ logo: [ @@ -133,7 +142,10 @@ describe('api/iiif/descriptive', () => { 'http://example.org/logos/institution2.jpg', ], }) - ).toEqual('http://example.org/logos/institution1.jpg'); + ).toEqual([ + 'http://example.org/logos/institution1.jpg', + 'http://example.org/logos/institution2.jpg', + ]); expect( getLogo({ logo: [ @@ -155,7 +167,24 @@ describe('api/iiif/descriptive', () => { }, ], }) - ).toEqual('http://example.org/logos/institution1.jpg'); + ).toEqual([ + { + '@id': 'http://example.org/logos/institution1.jpg', + service: { + '@context': 'http://iiif.io/api/image/2/context.json', + '@id': 'http://example.org/service/inst1', + profile: 'http://iiif.io/api/image/2/level2.json', + }, + }, + { + '@id': 'http://example.org/logos/institution2.jpg', + service: { + '@context': 'http://iiif.io/api/image/2/context.json', + '@id': 'http://example.org/service/inst1', + profile: 'http://iiif.io/api/image/2/level2.json', + }, + }, + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/image-resource/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/image-resource/descriptive-test.js index f1664913..bd946e3d 100644 --- a/packages/iiif-redux/__tests__/api/2.x/image-resource/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/image-resource/descriptive-test.js @@ -156,9 +156,9 @@ describe('api/2.x/imageResource/descriptive', () => { describe('getLogo', () => { it('should load logo from imageResource', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/manifest/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/manifest/descriptive-test.js index a22d2da9..68f407e8 100644 --- a/packages/iiif-redux/__tests__/api/2.x/manifest/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/manifest/descriptive-test.js @@ -152,9 +152,9 @@ describe('api/2.x/manifest/descriptive', () => { describe('getLogo', () => { it('should load logo from manifest', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/range/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/range/descriptive-test.js index 57cd2c64..fa49875b 100644 --- a/packages/iiif-redux/__tests__/api/2.x/range/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/range/descriptive-test.js @@ -151,9 +151,9 @@ describe('api/2.x/range/descriptive', () => { describe('getLogo', () => { it('should load logo from range', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/__tests__/api/2.x/sequence/descriptive-test.js b/packages/iiif-redux/__tests__/api/2.x/sequence/descriptive-test.js index fb9e8550..047e8896 100644 --- a/packages/iiif-redux/__tests__/api/2.x/sequence/descriptive-test.js +++ b/packages/iiif-redux/__tests__/api/2.x/sequence/descriptive-test.js @@ -153,9 +153,9 @@ describe('api/2.x/sequence/descriptive', () => { describe('getLogo', () => { it('should load logo from sequence', () => { - expect(getLogo(state)).toEqual( - 'http://example.org/logos/institution1.jpg' - ); + expect(getLogo(state)).toEqual([ + 'http://example.org/logos/institution1.jpg', + ]); }); }); }); diff --git a/packages/iiif-redux/src/api/2.x/iiif/descriptive.js b/packages/iiif-redux/src/api/2.x/iiif/descriptive.js index cb1a947d..16c99b31 100644 --- a/packages/iiif-redux/src/api/2.x/iiif/descriptive.js +++ b/packages/iiif-redux/src/api/2.x/iiif/descriptive.js @@ -28,7 +28,10 @@ const getLogo = resource => { if (!resource.logo) { return []; } - return resource.logo; + if (Array.isArray(resource.logo)) { + return resource.logo; + } + return [resource.logo]; }; export {