Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed Oct 28, 2018
1 parent cc25d1a commit e1d23c1
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
41 changes: 35 additions & 6 deletions packages/iiif-redux/__tests__/api/2.x/iiif/descriptive-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -118,22 +118,34 @@ 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: [
'http://example.org/logos/institution1.jpg',
'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: [
Expand All @@ -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',
},
},
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
});
5 changes: 4 additions & 1 deletion packages/iiif-redux/src/api/2.x/iiif/descriptive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e1d23c1

Please sign in to comment.