Skip to content

Commit f603921

Browse files
committed
Fixed tests
1 parent 8b2a6e4 commit f603921

File tree

11 files changed

+66
-34
lines changed

11 files changed

+66
-34
lines changed

packages/iiif-redux/__tests__/api/2.x/annotation-list/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ describe('api/2.x/annotationList/descriptive', () => {
156156

157157
describe('getLogo', () => {
158158
it('should load logo from annotationList', () => {
159-
expect(getLogo(state)).toEqual(
160-
'http://example.org/logos/institution1.jpg'
161-
);
159+
expect(getLogo(state)).toEqual([
160+
'http://example.org/logos/institution1.jpg',
161+
]);
162162
});
163163
});
164164
});

packages/iiif-redux/__tests__/api/2.x/annotation/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ describe('api/2.x/annotation/descriptive', () => {
156156

157157
describe('getLogo', () => {
158158
it('should load logo from annotation', () => {
159-
expect(getLogo(state)).toEqual(
160-
'http://example.org/logos/institution1.jpg'
161-
);
159+
expect(getLogo(state)).toEqual([
160+
'http://example.org/logos/institution1.jpg',
161+
]);
162162
});
163163
});
164164
});

packages/iiif-redux/__tests__/api/2.x/canvas/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ describe('api/2.x/canvas/descriptive', () => {
9393

9494
describe('getLogo', () => {
9595
it('should load logo from canvas', () => {
96-
expect(getLogo(state)).toEqual(
97-
'http://example.org/logos/institution1.jpg'
98-
);
96+
expect(getLogo(state)).toEqual([
97+
'http://example.org/logos/institution1.jpg',
98+
]);
9999
});
100100
});
101101

packages/iiif-redux/__tests__/api/2.x/collection/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ describe('api/2.x/collection/descriptive', () => {
9898

9999
describe('getLogo', () => {
100100
it('should load logo from collection', () => {
101-
expect(getLogo(state)).toEqual(
102-
'http://example.org/logos/institution1.jpg'
103-
);
101+
expect(getLogo(state)).toEqual([
102+
'http://example.org/logos/institution1.jpg',
103+
]);
104104
});
105105
});
106106

packages/iiif-redux/__tests__/api/2.x/external-resource/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ describe('api/2.x/external-resource/descriptive', () => {
157157

158158
describe('getLogo', () => {
159159
it('should load logo from externalResource', () => {
160-
expect(getLogo(state)).toEqual(
161-
'http://example.org/logos/institution1.jpg'
162-
);
160+
expect(getLogo(state)).toEqual([
161+
'http://example.org/logos/institution1.jpg',
162+
]);
163163
});
164164
});
165165
});

packages/iiif-redux/__tests__/api/2.x/iiif/descriptive-test.js

+35-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('api/iiif/descriptive', () => {
104104

105105
describe('getLogo', () => {
106106
it('should ignore missing logos', () => {
107-
expect(getLogo({})).toEqual(null);
107+
expect(getLogo({})).toEqual([]);
108108
});
109109
it('should unwrap service to ID', () => {
110110
expect(
@@ -118,22 +118,34 @@ describe('api/iiif/descriptive', () => {
118118
},
119119
},
120120
})
121-
).toEqual('http://example.org/logos/institution1.jpg');
121+
).toEqual([
122+
{
123+
'@id': 'http://example.org/logos/institution1.jpg',
124+
service: {
125+
'@context': 'http://iiif.io/api/image/2/context.json',
126+
'@id': 'http://example.org/service/inst1',
127+
profile: 'http://iiif.io/api/image/2/level2.json',
128+
},
129+
},
130+
]);
122131
expect(
123132
getLogo({
124133
logo: 'http://example.org/logos/institution1.jpg',
125134
})
126-
).toEqual('http://example.org/logos/institution1.jpg');
135+
).toEqual(['http://example.org/logos/institution1.jpg']);
127136
});
128-
it('should return the first service', () => {
137+
it('should return all images', () => {
129138
expect(
130139
getLogo({
131140
logo: [
132141
'http://example.org/logos/institution1.jpg',
133142
'http://example.org/logos/institution2.jpg',
134143
],
135144
})
136-
).toEqual('http://example.org/logos/institution1.jpg');
145+
).toEqual([
146+
'http://example.org/logos/institution1.jpg',
147+
'http://example.org/logos/institution2.jpg',
148+
]);
137149
expect(
138150
getLogo({
139151
logo: [
@@ -155,7 +167,24 @@ describe('api/iiif/descriptive', () => {
155167
},
156168
],
157169
})
158-
).toEqual('http://example.org/logos/institution1.jpg');
170+
).toEqual([
171+
{
172+
'@id': 'http://example.org/logos/institution1.jpg',
173+
service: {
174+
'@context': 'http://iiif.io/api/image/2/context.json',
175+
'@id': 'http://example.org/service/inst1',
176+
profile: 'http://iiif.io/api/image/2/level2.json',
177+
},
178+
},
179+
{
180+
'@id': 'http://example.org/logos/institution2.jpg',
181+
service: {
182+
'@context': 'http://iiif.io/api/image/2/context.json',
183+
'@id': 'http://example.org/service/inst1',
184+
profile: 'http://iiif.io/api/image/2/level2.json',
185+
},
186+
},
187+
]);
159188
});
160189
});
161190
});

packages/iiif-redux/__tests__/api/2.x/image-resource/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ describe('api/2.x/imageResource/descriptive', () => {
156156

157157
describe('getLogo', () => {
158158
it('should load logo from imageResource', () => {
159-
expect(getLogo(state)).toEqual(
160-
'http://example.org/logos/institution1.jpg'
161-
);
159+
expect(getLogo(state)).toEqual([
160+
'http://example.org/logos/institution1.jpg',
161+
]);
162162
});
163163
});
164164
});

packages/iiif-redux/__tests__/api/2.x/manifest/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ describe('api/2.x/manifest/descriptive', () => {
152152

153153
describe('getLogo', () => {
154154
it('should load logo from manifest', () => {
155-
expect(getLogo(state)).toEqual(
156-
'http://example.org/logos/institution1.jpg'
157-
);
155+
expect(getLogo(state)).toEqual([
156+
'http://example.org/logos/institution1.jpg',
157+
]);
158158
});
159159
});
160160
});

packages/iiif-redux/__tests__/api/2.x/range/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ describe('api/2.x/range/descriptive', () => {
151151

152152
describe('getLogo', () => {
153153
it('should load logo from range', () => {
154-
expect(getLogo(state)).toEqual(
155-
'http://example.org/logos/institution1.jpg'
156-
);
154+
expect(getLogo(state)).toEqual([
155+
'http://example.org/logos/institution1.jpg',
156+
]);
157157
});
158158
});
159159
});

packages/iiif-redux/__tests__/api/2.x/sequence/descriptive-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ describe('api/2.x/sequence/descriptive', () => {
153153

154154
describe('getLogo', () => {
155155
it('should load logo from sequence', () => {
156-
expect(getLogo(state)).toEqual(
157-
'http://example.org/logos/institution1.jpg'
158-
);
156+
expect(getLogo(state)).toEqual([
157+
'http://example.org/logos/institution1.jpg',
158+
]);
159159
});
160160
});
161161
});

packages/iiif-redux/src/api/2.x/iiif/descriptive.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ const getLogo = resource => {
2828
if (!resource.logo) {
2929
return [];
3030
}
31-
return resource.logo;
31+
if (Array.isArray(resource.logo)) {
32+
return resource.logo;
33+
}
34+
return [resource.logo];
3235
};
3336

3437
export {

0 commit comments

Comments
 (0)