diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-03-02 22:20:47 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-03-02 22:20:47 -0500 |
commit | 7a51a0fbde445e346a83982dd6a16ce164521e26 (patch) | |
tree | 0d19ad4839622f1a5c375a89f6719b64b9a83a83 /test/test-document.js | |
parent | 46fee07d36b3966af9bacca8c6253b044bde07ee (diff) |
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}); |