You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/07/18 15:09:38 UTC
[incubator-annotator] 01/01: Add failing test for range without
Text nodes
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch test-empty-range
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 021398575d3dad6ecd61d22c069358e2c298e991
Author: Gerben <ge...@treora.com>
AuthorDate: Thu Jun 25 23:38:11 2020 +0200
Add failing test for range without Text nodes
---
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 f962157..50e39f0 100644
--- a/packages/dom/test/text-quote/describe.test.ts
+++ b/packages/dom/test/text-quote/describe.test.ts
@@ -72,6 +72,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: ': ',
+ suffix: '',
+ });
+ })
+
describe('inverts test cases of text quote matcher', () => {
const applicableTestCases = Object.entries(testMatchCases)
.filter(([_, { expected }]) => expected.length > 0);