diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-03-04 21:24:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 21:24:39 -0500 |
commit | 421b60db0f6f132cbc5993488041846055a76d11 (patch) | |
tree | b2b28efc8ed7651c63ca2e728096ab79c6e6ab06 /test/test-document.js | |
parent | 6e47b4e241594d68384f62b1faa34c86f85addbf (diff) | |
parent | 7a51a0fbde445e346a83982dd6a16ce164521e26 (diff) |
Merge pull request #387 from toasted-nutbread/yomichan-vm
Abstract Yomichan extension script execution
Diffstat (limited to 'test/test-document.js')
-rw-r--r-- | test/test-document.js | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/test/test-document.js b/test/test-document.js index edf6bbea..ab5f5716 100644 --- a/test/test-document.js +++ b/test/test-document.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); const assert = require('assert'); const {JSDOM} = require('jsdom'); -const yomichanTest = require('./yomichan-test'); +const {VM} = require('./yomichan-vm'); // DOMRect class definition @@ -74,20 +74,18 @@ async function testDocument1() { const Node = window.Node; const Range = window.Range; - const {DOM} = yomichanTest.requireScript( - 'ext/mixed/js/dom.js', - ['DOM'] - ); - const {TextSourceRange, TextSourceElement} = yomichanTest.requireScript( - 'ext/fg/js/source.js', - ['TextSourceRange', 'TextSourceElement'], - {document, window, Range, Node} - ); - const {docRangeFromPoint, docSentenceExtract} = yomichanTest.requireScript( - 'ext/fg/js/document.js', - ['docRangeFromPoint', 'docSentenceExtract'], - {document, window, Node, TextSourceElement, TextSourceRange, DOM} - ); + const vm = new VM({document, window, Range, Node}); + vm.execute([ + 'mixed/js/dom.js', + 'fg/js/source.js', + 'fg/js/document.js' + ]); + const [TextSourceRange, TextSourceElement, docRangeFromPoint, docSentenceExtract] = vm.get([ + 'TextSourceRange', + 'TextSourceElement', + 'docRangeFromPoint', + 'docSentenceExtract' + ]); try { await testDocumentTextScanningFunctions(dom, {docRangeFromPoint, docSentenceExtract, TextSourceRange, TextSourceElement}); |