Commit 9b9f56c9 authored by Robert Knight's avatar Robert Knight

Add additional tests for failing position and range selectors

parent 27f04b76
...@@ -192,6 +192,11 @@ describe('HTML anchoring', function () { ...@@ -192,6 +192,11 @@ describe('HTML anchoring', function () {
}, testCases); }, testCases);
describe('When anchoring fails', function () { describe('When anchoring fails', function () {
var validQuoteSelector = {
type: 'TextQuoteSelector',
exact: 'Lorem ipsum',
};
it('throws an error if anchoring using a quote fails', function () { it('throws an error if anchoring using a quote fails', function () {
var quoteSelector = { var quoteSelector = {
type: 'TextQuoteSelector', type: 'TextQuoteSelector',
...@@ -202,6 +207,32 @@ describe('HTML anchoring', function () { ...@@ -202,6 +207,32 @@ describe('HTML anchoring', function () {
assert.equal(result.error.message, 'Quote not found'); assert.equal(result.error.message, 'Quote not found');
}); });
}); });
it('does not throw an error if anchoring using a position fails', function () {
var positionSelector = {
type: 'TextPositionSelector',
start: 1000,
end: 1010,
};
// Providing an annotation has quote selector that anchors, a position
// selector which fails to anchor should be ignored.
return html.anchor(container, [positionSelector, validQuoteSelector]);
});
it('does not throw an error if anchoring using a range fails', function () {
var rangeSelector = {
type: 'RangeSelector',
startContainer: '/main',
startOffset: 1,
endContainer: '/main',
endOffset: 5,
};
// Providing an annotation has quote selector that anchors, a range
// selector which fails to anchor should be ignored.
return html.anchor(container, [rangeSelector, validQuoteSelector]);
});
}); });
describe('Web page baselines', function () { describe('Web page baselines', function () {
......
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