diff --git a/__tests__/paintable-helper.tests.ts b/__tests__/paintable-helper.tests.ts index 5c298e8..f5c3950 100644 --- a/__tests__/paintable-helper.tests.ts +++ b/__tests__/paintable-helper.tests.ts @@ -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'; @@ -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"`); + }); }); diff --git a/fixtures/cookbook/multimedia.json b/fixtures/cookbook/multimedia.json new file mode 100644 index 0000000..76e66b5 --- /dev/null +++ b/fixtures/cookbook/multimedia.json @@ -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" + } + ] + } + ] + } + ] +}