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:37 UTC

[incubator-annotator] branch test-empty-range created (now 0213985)

This is an automated email from the ASF dual-hosted git repository.

gerben pushed a change to branch test-empty-range
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git.


      at 0213985  Add failing test for range without Text nodes

This branch includes the following new commits:

     new 0213985  Add failing test for range without Text nodes

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-annotator] 01/01: Add failing test for range without Text nodes

Posted by ge...@apache.org.
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);