Repository navigation
Expand file tree
/
Copy pathitems.test.js
More file actions
123 lines (107 loc) · 3.94 KB
/
Copy pathitems.test.js
File metadata and controls
123 lines (107 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use strict";
const chai = require("chai");
const expect = chai.expect;
const items = requireSource("api/response/iiif/presentation-api/items");
describe("IIIF response presentation API items helpers", () => {
const accessImage = {
duration: null,
height: 3024,
id: "076dcbd8-8c57-40e8-bdf7-dc9153c87a36",
label: "Access File - Tiff",
mime_type: "image/tiff",
original_filename: "Squirrel.tif",
poster_offset: null,
rank: 0,
representative_image_url:
"https://iiif.stack.rdc-staging.library.northwestern.edu/iiif/2/076dcbd8-8c57-40e8-bdf7-dc9153c87a36",
role: "Access",
streaming_url: null,
webvtt: null,
width: 4032,
};
// const accessAudio = {
// duration: null,
// height: 3024,
// id: "076dcbd8-8c57-40e8-bdf7-dc9153c87a36",
// label: "Access File - Tiff",
// mime_type: "image/tiff",
// original_filename: "Squirrel.tif",
// poster_offset: null,
// rank: 0,
// representative_image_url:
// "https://iiif.stack.rdc-staging.library.northwestern.edu/iiif/2/076dcbd8-8c57-40e8-bdf7-dc9153c87a36",
// role: "Access",
// streaming_url: null,
// webvtt: null,
// width: 4032,
// };
it("annotationType(workType)", () => {
expect(items.annotationType("Audio")).to.eq("Sound");
expect(items.annotationType("Image")).to.eq("Image");
expect(items.annotationType("Video")).to.eq("Video");
});
it("buildAnnotationBody(fileSet, workType)", () => {
const body = items.buildAnnotationBody(accessImage, "Image");
expect(body.id).contains(accessImage.representative_image_url);
expect(body.width).to.eq(accessImage.width);
expect(body.format).to.eq(accessImage.mime_type);
expect(body.service[0].id).to.eq(accessImage.representative_image_url);
});
it("buildAnnotationBody(fileSet, workType)", () => {
const bodyId = items.buildAnnotationBodyId(accessImage, "Image");
expect(bodyId).eq(
`${accessImage.representative_image_url}/full/600,/0/default.jpg`
);
});
it('buildImageResourceId(representativeImageUrl,size = "!300,300")', () => {
expect(
items.buildImageResourceId(accessImage.representative_image_url)
).to.eq(
`${accessImage.representative_image_url}/full/!300,300/0/default.jpg`
);
expect(
items.buildImageResourceId(
accessImage.representative_image_url,
"1000,1000"
)
).to.eq(
`${accessImage.representative_image_url}/full/1000,1000/0/default.jpg`
);
});
it("buildImageService(representativeImageUrl)", () => {
const imageService = items.buildImageService(
accessImage.representative_image_url
)[0];
expect(imageService.id).to.eq(accessImage.representative_image_url);
expect(imageService.profile).to.eq(
"http://iiif.io/api/image/3/level2.json"
);
expect(imageService.type).to.eq("ImageService3");
});
it("buildSupplementingAnnotation({ canvasId, fileSet })", () => {
const canvasId = "https://example.com/canvas/1";
const annotation = items.buildSupplementingAnnotation({
canvasId,
fileSet: accessImage,
});
expect(annotation.id).to.eq(`${canvasId}/annotations/page/0/a0`);
expect(annotation.type).to.eq("Annotation");
expect(annotation.motivation).to.eq("supplementing");
expect(annotation.body.id).to.eq(accessImage.webvtt);
expect(annotation.body.type).to.eq("Text");
expect(annotation.body.format).to.eq("text/vtt");
expect(annotation.body.language).to.eq("none");
expect(annotation.target).to.eq(canvasId);
});
it("isAudioVideo(workType)", () => {
expect(items.isAudioVideo("Audio")).to.be.true;
expect(items.isAudioVideo("Image")).to.be.false;
expect(items.isAudioVideo("Sound")).to.be.true;
expect(items.isAudioVideo("Video")).to.be.true;
});
it("isImage(workType)", () => {
expect(items.isImage("Audio")).to.be.false;
expect(items.isImage("Image")).to.be.true;
expect(items.isImage("Video")).to.be.false;
});
});