diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-08-09 13:27:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-09 13:27:21 -0400 |
commit | 6da02c6eee803756d9a9075bfde333eeb31ce64b (patch) | |
tree | 158d81b89ca99095c06db31c1ebc7bb46a57c33a /test | |
parent | 480e0e15e3109165d077c18985893d7cca79959e (diff) |
document.js refactor (#719)
* Refactor document.js into a class
* Move public functions first
* Rename private functions
* Rename
* Rename argument
* Use instance of DocumentUtil
* Update tests
* Refactor
* Rename (test-)document.js to (test-)document-util.js
Diffstat (limited to 'test')
-rw-r--r-- | test/test-document-util.js (renamed from test/test-document.js) | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/test-document.js b/test/test-document-util.js index ba7acc49..40b65ed1 100644 --- a/test/test-document.js +++ b/test/test-document-util.js @@ -96,25 +96,24 @@ async function testDocument1() { 'mixed/js/dom.js', 'fg/js/dom-text-scanner.js', 'fg/js/source.js', - 'fg/js/document.js' + 'fg/js/document-util.js' ]); - const [DOMTextScanner, TextSourceRange, TextSourceElement, docRangeFromPoint, docSentenceExtract] = vm.get([ + const [DOMTextScanner, TextSourceRange, TextSourceElement, DocumentUtil] = vm.get([ 'DOMTextScanner', 'TextSourceRange', 'TextSourceElement', - 'docRangeFromPoint', - 'docSentenceExtract' + 'DocumentUtil' ]); try { - await testDocumentTextScanningFunctions(dom, {docRangeFromPoint, docSentenceExtract, TextSourceRange, TextSourceElement}); + await testDocumentTextScanningFunctions(dom, {DocumentUtil, TextSourceRange, TextSourceElement}); await testTextSourceRangeSeekFunctions(dom, {DOMTextScanner}); } finally { window.close(); } } -async function testDocumentTextScanningFunctions(dom, {docRangeFromPoint, docSentenceExtract, TextSourceRange, TextSourceElement}) { +async function testDocumentTextScanningFunctions(dom, {DocumentUtil, TextSourceRange, TextSourceElement}) { const document = dom.window.document; for (const testElement of document.querySelectorAll('.test[data-test-type=scan]')) { @@ -163,7 +162,8 @@ async function testDocumentTextScanningFunctions(dom, {docRangeFromPoint, docSen }; // Test docRangeFromPoint - const source = docRangeFromPoint(0, 0, false); + const documentUtil = new DocumentUtil(); + const source = documentUtil.getRangeFromPoint(0, 0, false); switch (resultType) { case 'TextSourceRange': assert.strictEqual(getPrototypeOfOrNull(source), TextSourceRange.prototype); @@ -181,7 +181,7 @@ async function testDocumentTextScanningFunctions(dom, {docRangeFromPoint, docSen if (source === null) { continue; } // Test docSentenceExtract - const sentenceActual = docSentenceExtract(source, sentenceExtent, false).text; + const sentenceActual = documentUtil.extractSentence(source, sentenceExtent, false).text; assert.strictEqual(sentenceActual, sentence); // Clean |