Commit 41bb7d05 authored by Robert Knight's avatar Robert Knight

Add additional tests for `describe` being passed invalid ranges

parent fa1474e0
......@@ -159,16 +159,43 @@ describe('annotator/anchoring/pdf', function () {
});
});
it('rejects when text selection spans multiple pages', () => {
it('throws if range spans multiple pages', async () => {
viewer.pdfViewer.setCurrentPage(2, 3);
const range = findText(container, 'occupied again? NODE A');
return pdfAnchoring.describe(container, range).catch(err => {
assert.equal(
err.message,
await assert.rejects(
pdfAnchoring.describe(container, range),
'Selecting across page breaks is not supported'
);
});
it('throws if range is outside the text layer', async () => {
viewer.pdfViewer.setCurrentPage(2, 3);
const range = new Range();
const el = document.createElement('div');
el.append('foobar');
range.setStart(el.firstChild, 0);
range.setEnd(el.firstChild, 6);
await assert.rejects(
pdfAnchoring.describe(container, range),
'Selection is outside page text'
);
});
it('throws if range does not contain any text nodes', async () => {
viewer.pdfViewer.setCurrentPage(2, 3);
const range = new Range();
const el = document.createElement('div');
range.setStart(el, 0);
range.setEnd(el, 0);
await assert.rejects(
pdfAnchoring.describe(container, range),
'Selection does not contain text'
);
});
});
......
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