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 2021/06/25 08:55:49 UTC
[incubator-annotator] 01/03: Test for range without Text nodes
(describe text quote)
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 <ge...@treora.com>
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,