This is an automated email from the ASF dual-hosted git repository. gerben pushed a commit to branch improve-range-stuff in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 6a790ffcf39f6d3308ad17e0bc6ad4e36c454de6 Author: Gerben <[email protected]> AuthorDate: Tue Sep 15 19:48:35 2020 +0200 Update test names and tweak some tests. All scopes are ranges now. --- packages/dom/test/text-quote/match.test.ts | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/packages/dom/test/text-quote/match.test.ts b/packages/dom/test/text-quote/match.test.ts index 7bdd83c..7d52e15 100644 --- a/packages/dom/test/text-quote/match.test.ts +++ b/packages/dom/test/text-quote/match.test.ts @@ -95,36 +95,26 @@ describe('createTextQuoteSelectorMatcher', () => { ]); }); - it('works with parent of text as scope', async () => { - const { html, selector, expected } = testCases['simple']; - const doc = domParser.parseFromString(html, 'text/html'); - - const scope = doc.createRange(); - scope.selectNodeContents(evaluateXPath(doc, '//b')); - - await testMatcher(doc, scope, selector, expected); - }); - - it('works with parent of text as scope, when matching its first characters', async () => { + it('works when scope spans one text node’s contents, matching its first characters', async () => { const { html, selector, expected } = testCases['first characters']; const doc = domParser.parseFromString(html, 'text/html'); const scope = doc.createRange(); - scope.selectNodeContents(evaluateXPath(doc, '//b')); + scope.selectNodeContents(evaluateXPath(doc, '//b/text()')); await testMatcher(doc, scope, selector, expected); }); - it('works with parent of text as scope, when matching its first characters, with an empty text node', async () => { + it('works when scope starts with an empty text node, matching its first characters', async () => { const { html, selector } = testCases['first characters']; const doc = domParser.parseFromString(html, 'text/html'); - const scope = doc.createRange(); - scope.selectNodeContents(evaluateXPath(doc, '//b')); - const textNode = evaluateXPath(doc, '//b/text()') as Text; textNode.splitText(0); + const scope = doc.createRange(); + scope.selectNodeContents(evaluateXPath(doc, '//b')); + await testMatcher(doc, scope, selector, [ { startContainerXPath: '//b/text()[2]', @@ -135,7 +125,7 @@ describe('createTextQuoteSelectorMatcher', () => { ]); }); - it('works when scope is a Range within one text node', async () => { + it('works when scope has both ends within one text node', async () => { const { html, selector, expected } = testCases['simple']; const doc = domParser.parseFromString(html, 'text/html'); @@ -146,7 +136,7 @@ describe('createTextQuoteSelectorMatcher', () => { await testMatcher(doc, scope, selector, expected); }); - it('works when scope is a Range with both ends inside text nodes', async () => { + it('works when scope has both ends inside text nodes', async () => { const { html, selector, expected } = testCases['across elements']; const doc = domParser.parseFromString(html, 'text/html'); @@ -157,7 +147,7 @@ describe('createTextQuoteSelectorMatcher', () => { await testMatcher(doc, scope, selector, expected); }); - it('works when scope is a Range with both ends inside elements', async () => { + it('works when scope has both ends inside an element', async () => { const { html, selector, expected } = testCases['across elements']; const doc = domParser.parseFromString(html, 'text/html');
