Commit 445bfef7 authored by Robert Knight's avatar Robert Knight

Add tests to clarify what is expected if CFIs or URLs match but not both

parent 5cb7fb17
......@@ -64,6 +64,26 @@ describe('annotationMatchesSegment', () => {
selector: { type: 'EPUBContentSelector', url: '/chapters/04.xhtml' },
expected: false,
},
// CFIs do not match but URLs do. The successful match wins.
{
segment: { cfi: '/2', url: '/chapters/02.xhtml' },
selector: {
type: 'EPUBContentSelector',
cfi: '/4',
url: '/chapters/02.xhtml',
},
expected: true,
},
// CFIs match but URLs do not. The successful match wins.
{
segment: { cfi: '/2', url: '/chapters/03.xhtml' },
selector: {
type: 'EPUBContentSelector',
cfi: '/2',
url: '/chapters/02.xhtml',
},
expected: true,
},
].forEach(({ segment, selector, expected }, index) => {
it(`returns true if CFI or URL matches current segment (${index})`, () => {
const ann = { target: [{ selector: [selector] }] };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment