-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6229 from wellcomecollection/repetitive-structures
Repetitive structures
- Loading branch information
Showing
5 changed files
with
145 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { getCanvases, groupStructures } from '../../utils/iiif'; | ||
import manifest from '../../../common/__mocks__/iiif-manifest'; | ||
|
||
const canvases = getCanvases(manifest); | ||
const structures = [ | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-0', | ||
'@type': 'sc:Range', | ||
label: 'First', | ||
canvases: [ | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c0', | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c1', | ||
], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-1', | ||
'@type': 'sc:Range', | ||
label: 'First', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c2'], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-2', | ||
'@type': 'sc:Range', | ||
label: 'First', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c5'], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-3', | ||
'@type': 'sc:Range', | ||
label: 'Second', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c6'], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-4', | ||
'@type': 'sc:Range', | ||
label: 'Third', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c8'], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-5', | ||
'@type': 'sc:Range', | ||
label: 'Third', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c9'], | ||
}, | ||
]; | ||
|
||
const correctResult = [ | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-0', | ||
'@type': 'sc:Range', | ||
label: 'First', | ||
canvases: [ | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c0', | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c1', | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c2', | ||
], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-2', | ||
'@type': 'sc:Range', | ||
label: 'First', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c5'], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-3', | ||
'@type': 'sc:Range', | ||
label: 'Second', | ||
canvases: ['https://wellcomelibrary.org/iiif/b21538906/canvas/c6'], | ||
}, | ||
{ | ||
'@id': 'https://wellcomelibrary.org/iiif/b21538906/range/r-4', | ||
'@type': 'sc:Range', | ||
label: 'Third', | ||
canvases: [ | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c8', | ||
'https://wellcomelibrary.org/iiif/b21538906/canvas/c9', | ||
], | ||
}, | ||
]; | ||
describe('Group repetitive iiif structures', () => { | ||
it('groups iiifStructures with consecutive canvases and the same label', () => { | ||
const groupedStructures = groupStructures(canvases, structures); | ||
expect(groupedStructures).toEqual(correctResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters