Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
ea547a84
Commit
ea547a84
authored
Mar 30, 2021
by
Mark A. Matney, Jr
Browse files
Options
Downloads
Patches
Plain Diff
Use real resource types in the test data
parent
e2220c17
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
__tests__/src/lib/ThumbnailFactory.test.js
+18
-9
18 additions, 9 deletions
__tests__/src/lib/ThumbnailFactory.test.js
with
18 additions
and
9 deletions
__tests__/src/lib/ThumbnailFactory.test.js
+
18
−
9
View file @
ea547a84
...
...
@@ -6,7 +6,10 @@ const manifest = Utils.parseManifest(fixture);
const
canvas
=
manifest
.
getSequences
()[
0
].
getCanvases
()[
0
];
/** */
function
createSubject
(
jsonld
,
iiifOpts
)
{
function
createSubject
(
jsonld
,
resourceType
,
iiifOpts
)
{
if
(
resourceType
===
'
Image
'
)
{
return
createImageSubject
(
jsonld
,
iiifOpts
);
}
return
getThumbnail
(
new
ManifestResource
(
jsonld
,
{}),
iiifOpts
);
}
...
...
@@ -43,36 +46,42 @@ describe('getThumbnail', () => {
{
height
:
1000
,
width
:
1000
},
];
describe
(
'
with a IIIF resource
'
,
()
=>
{
for
(
const
type
of
[
'
Collection
'
,
'
Manifest
'
,
'
Canvas
'
,
'
Image
'
])
{
describe
(
'
with a thumbnail
'
,
()
=>
{
it
(
'
return the thumbnail and metadata
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
{
'
@id
'
:
url
,
height
:
70
,
width
:
50
}
})).
toMatchObject
({
height
:
70
,
url
,
width
:
50
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
{
'
@id
'
:
url
,
height
:
70
,
width
:
50
}
}
,
type
)).
toMatchObject
({
height
:
70
,
url
,
width
:
50
});
});
it
(
'
return the IIIF service of the thumbnail
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
iiifLevel1Service
})).
toMatchObject
({
url
:
`
${
url
}
/full/,120/0/default.jpg`
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
iiifLevel1Service
}
,
type
)).
toMatchObject
({
url
:
`
${
url
}
/full/,120/0/default.jpg`
});
});
describe
(
'
with image size constraints
'
,
()
=>
{
it
(
'
does nothing with a static resource
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
{
'
@id
'
:
url
}
},
{
maxWidth
:
50
})).
toMatchObject
({
url
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
{
'
@id
'
:
url
}
},
type
,
{
maxWidth
:
50
})).
toMatchObject
({
url
});
});
it
(
'
does nothing with a IIIF level 0 service
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
iiifLevel0Service
},
{
maxWidth
:
50
})).
toMatchObject
({
url
:
'
arbitrary-url
'
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
iiifLevel0Service
},
type
,
{
maxWidth
:
50
})).
toMatchObject
({
url
:
'
arbitrary-url
'
});
});
it
(
'
calculates constraints for a IIIF level 1 service
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
iiifLevel1Service
},
{
maxWidth
:
150
})).
toMatchObject
({
height
:
300
,
url
:
`
${
url
}
/full/150,/0/default.jpg`
,
width
:
150
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
iiifLevel1Service
},
type
,
{
maxWidth
:
150
})).
toMatchObject
({
height
:
300
,
url
:
`
${
url
}
/full/150,/0/default.jpg`
,
width
:
150
});
});
it
(
'
calculates constraints for a IIIF level 2 service
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
iiifLevel2Service
},
{
maxHeight
:
200
,
maxWidth
:
150
})).
toMatchObject
({
height
:
200
,
url
:
`
${
url
}
/full/!150,200/0/default.jpg`
,
width
:
100
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
iiifLevel2Service
},
type
,
{
maxHeight
:
200
,
maxWidth
:
150
})).
toMatchObject
({
height
:
200
,
url
:
`
${
url
}
/full/!150,200/0/default.jpg`
,
width
:
100
});
});
it
(
'
applies a minumum size to image constraints to encourage asset reuse
'
,
()
=>
{
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
'
Whatever
'
,
thumbnail
:
iiifLevel2Service
},
{
maxHeight
:
100
,
maxWidth
:
100
})).
toMatchObject
({
height
:
120
,
url
:
`
${
url
}
/full/!120,120/0/default.jpg`
,
width
:
60
});
expect
(
createSubject
({
'
@id
'
:
'
xyz
'
,
'
@type
'
:
type
,
thumbnail
:
iiifLevel2Service
},
type
,
{
maxHeight
:
100
,
maxWidth
:
100
})).
toMatchObject
({
height
:
120
,
url
:
`
${
url
}
/full/!120,120/0/default.jpg`
,
width
:
60
});
});
});
});
}
});
describe
(
'
with an image resource
'
,
()
=>
{
...
...
@@ -125,7 +134,7 @@ describe('getThumbnail', () => {
describe
(
'
with a canvas
'
,
()
=>
{
it
(
'
uses the thumbnail
'
,
()
=>
{
expect
(
createSubject
({
...
canvas
.
__jsonld
,
thumbnail
:
{
...
iiifLevel1Service
}
})).
toMatchObject
({
url
:
`
${
url
}
/full/,120/0/default.jpg`
});
expect
(
createSubject
({
...
canvas
.
__jsonld
,
thumbnail
:
{
...
iiifLevel1Service
}
}
,
'
Canvas
'
)).
toMatchObject
({
url
:
`
${
url
}
/full/,120/0/default.jpg`
});
});
it
(
'
uses the first image resource
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment