aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-31 14:46:09 -0400
committerGitHub <noreply@github.com>2021-07-31 14:46:09 -0400
commit8c4a50f68c9543c14cfe76abd2f6f42135b0e13d (patch)
tree9c7f252952a37b117f298b9b08a6c07418049c7f /test
parent992c8bcf75b9477e1652cf2a458418e375903cc0 (diff)
DictionaryImporterThreaded (#1865)
* Create new classes for importing dictionaries from a separate thread * Use threaded importer * Update worker tests
Diffstat (limited to 'test')
-rw-r--r--test/test-workers.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test-workers.js b/test/test-workers.js
index 9f9c4d13..6cc77823 100644
--- a/test/test-workers.js
+++ b/test/test-workers.js
@@ -22,6 +22,13 @@ const {VM} = require('../dev/vm');
const assert = require('assert');
+class StubClass {
+ prepare() {
+ // NOP
+ }
+}
+
+
function loadEslint() {
return JSON.parse(fs.readFileSync(path.join(__dirname, '..', '.eslintrc.json'), {encoding: 'utf8'}));
}
@@ -87,9 +94,36 @@ function testServiceWorker() {
assert.deepStrictEqual(swRules.files, expectedSwRulesFiles);
}
+function testWorkers() {
+ testWorker(
+ 'js/language/dictionary-importer-worker-main.js',
+ {DictionaryImporterWorker: StubClass}
+ );
+}
+
+function testWorker(scriptPath, fields) {
+ // Get script paths
+ const scripts = getImportedScripts(scriptPath, fields);
+
+ // Verify that eslint config lists files correctly
+ const expectedRulesFiles = filterScriptPaths(scripts);
+ const expectedRulesFilesSet = new Set(expectedRulesFiles);
+ const eslintConfig = loadEslint();
+ const rules = eslintConfig.overrides.find((item) => (
+ typeof item.env === 'object' &&
+ item.env !== null &&
+ item.env.worker === true
+ ));
+ assert.ok(typeof rules !== 'undefined');
+ assert.ok(Array.isArray(rules.files));
+ assert.deepStrictEqual(rules.files.filter((v) => expectedRulesFilesSet.has(v)), expectedRulesFiles);
+}
+
+
function main() {
try {
testServiceWorker();
+ testWorkers();
} catch (e) {
console.error(e);
process.exit(-1);