Skip to content

Commit

Permalink
Added media test
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed Jun 24, 2024
1 parent 7ac8893 commit e27571f
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
17 changes: 17 additions & 0 deletions __tests__/paintable-helper.tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, test, expect } from 'vitest';
import choice from '../fixtures/cookbook/choice.json';
import composite from '../fixtures/cookbook/composite.json';
import multimedia from '../fixtures/cookbook/multimedia.json';
import { Vault } from '../src/vault';
import invariant from 'tiny-invariant';
import { createPaintingAnnotationsHelper } from '../src/painting-annotations';
Expand Down Expand Up @@ -33,4 +34,20 @@ describe('getPaintables', () => {
'https://iiif.io/api/image/3.0/example/reference/899da506920824588764bc12b10fc800-bnf_chateauroux_miniature/full/max/0/native.jpg'
);
});

test('multimedia', async () => {
const vault = new Vault();
const manifest = await vault.loadManifest(multimedia.id, multimedia);

expect(manifest).to.exist;
invariant(manifest);

const canvases = vault.get(manifest.items);
const painting = createPaintingAnnotationsHelper(vault);
const paintables = painting.getPaintables(canvases[0]);

expect(paintables.items).toHaveLength(2);
expect(paintables.items[0].resource.id).toMatchInlineSnapshot(`"https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen/full/max/0/default.jpg"`);
expect(paintables.items[1].resource.id).toMatchInlineSnapshot(`"https://fixtures.iiif.io/video/indiana/donizetti-elixir/vae0637_accessH264_low_act_1.mp4"`);
});
});
59 changes: 59 additions & 0 deletions fixtures/cookbook/multimedia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/manifest.json",
"type": "Manifest",
"label": {
"en": ["Multimedia Canvas"]
},
"items": [
{
"id": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/canvas",
"type": "Canvas",
"height": 3024,
"width": 4032,
"duration": 120,
"items": [
{
"id": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/page/p1/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/annotation/p0001-image",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"height": 3024,
"width": 4032,
"service": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen",
"profile": "level1",
"type": "ImageService3"
}
]
},
"target": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/canvas"
},
{
"id": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/annotation/p0002-video q",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://fixtures.iiif.io/video/indiana/donizetti-elixir/vae0637_accessH264_low_act_1.mp4",
"type": "Video",
"format": "video/mp4",
"height": 360,
"width": 480,
"duration": 3971.24
},
"target": "https://preview.iiif.io/cookbook/0489-multimedia-canvas/recipe/0489-multimedia-canvas/canvas#xywh=200,200,480,360&t=27,57"
}
]
}
]
}
]
}

0 comments on commit e27571f

Please sign in to comment.