This is an automated email from the ASF dual-hosted git repository. gerben pushed a commit to branch simpler-matcher-creation in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 88baa297f2abc050e2d90c82d3c6216415896ae7 Author: Gerben <[email protected]> AuthorDate: Thu Jun 25 23:38:11 2020 +0200 Test for range without Text nodes (describe text quote) --- packages/dom/test/text-quote/describe.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/dom/test/text-quote/describe.test.ts b/packages/dom/test/text-quote/describe.test.ts index b0113e0..ceed528 100644 --- a/packages/dom/test/text-quote/describe.test.ts +++ b/packages/dom/test/text-quote/describe.test.ts @@ -120,6 +120,20 @@ describe('describeTextQuote', () => { assert.deepEqual(result, expected); }); + it('works if range does not contain Text nodes', async () => { + const html = `<b>Try quoting this image: <img/> — would that work?</b>` + const doc = domParser.parseFromString(html, 'text/html'); + const range = document.createRange(); + range.selectNode(evaluateXPath(doc, '//img')); + const result = await describeTextQuote(range, doc); + assert.deepEqual(result, { + type: 'TextQuoteSelector', + exact: '', + prefix: 'image: ', + suffix: ' —', + }); + }); + describe('inverts test cases of text quote matcher', () => { const applicableTestCases = Object.entries(testMatchCases).filter( ([_, { expected }]) => expected.length > 0,
