Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions __tests__/image-3-parser/supports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
supports,
imageServiceSupportsRequest,
imageServiceSupportsFormat,
getImageServiceLevel,
} from '../../src/image-3';

describe('supports', function () {
Expand Down Expand Up @@ -175,6 +176,17 @@ describe('supports', function () {
});

describe('imageServiceSupportsRequest', () => {
test('bfn image service level', () => {
const service = {
profile: 'http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2',
width: 4564,
height: 6174,
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
'@id': 'https://gallica.bnf.fr/iiif/ark:/12148/bpt6k11620688/f1',
} as ImageService;

expect(getImageServiceLevel(service)).toEqual(2);
});
test('sample image service (v2)', () => {
const u = parseImageServiceRequest;
const service2: ImageService = {
Expand Down
8 changes: 4 additions & 4 deletions src/image-3/utilities/get-image-service-level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export function getImageServiceLevel(service: ImageService): null | number {
if (!isImageService(service)) {
return null;
}
if (isImageServiceLevel(0, service)) {
return 0;
if (isImageServiceLevel(2, service)) {
return 2;
}
if (isImageServiceLevel(1, service)) {
return 1;
}
if (isImageServiceLevel(2, service)) {
return 2;
if (isImageServiceLevel(0, service)) {
return 0;
}
return null;
}