summaryrefslogtreecommitdiff
path: root/test/fixtures/translator-test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-01-31 08:38:30 -0500
committerGitHub <noreply@github.com>2024-01-31 13:38:30 +0000
commit87ed7c8affd3ade9d3cd2d9ed1a61dd5f224e473 (patch)
treebe727294e31ef21e8a3f634734610e69e4a155ac /test/fixtures/translator-test.js
parent3e419aa562aab03ca20421aaf7e4d1a39194a5b4 (diff)
Module refactoring (#588)
* Convert PronunciationGenerator into static functions * Convert DictionaryDataUtil into static functions * Convert AnkiNoteDataCreator into static functions * Convert MediaUtil into static functions * Convert RegexUtil into static functions * Convert StringUtil into static functions * Convert ArrayBufferUtil into static functions * Convert AnkiUtil into static functions * Convert PermissionsUtil into static functions * Convert ProfileConditionsUtil into static functions
Diffstat (limited to 'test/fixtures/translator-test.js')
-rw-r--r--test/fixtures/translator-test.js21
1 files changed, 6 insertions, 15 deletions
diff --git a/test/fixtures/translator-test.js b/test/fixtures/translator-test.js
index 58247b70..d1b3de8b 100644
--- a/test/fixtures/translator-test.js
+++ b/test/fixtures/translator-test.js
@@ -23,7 +23,6 @@ import {dirname, join} from 'path';
import {expect, vi} from 'vitest';
import {parseJson} from '../../dev/json.js';
import {createDictionaryArchive} from '../../dev/util.js';
-import {AnkiNoteDataCreator} from '../../ext/js/data/sandbox/anki-note-data-creator.js';
import {DictionaryDatabase} from '../../ext/js/dictionary/dictionary-database.js';
import {DictionaryImporter} from '../../ext/js/dictionary/dictionary-importer.js';
import {Translator} from '../../ext/js/language/translator.js';
@@ -42,7 +41,7 @@ vi.stubGlobal('chrome', chrome);
/**
* @param {string} dictionaryDirectory
* @param {string} dictionaryName
- * @returns {Promise<{translator: Translator, ankiNoteDataCreator: AnkiNoteDataCreator}>}
+ * @returns {Promise<Translator>}
*/
async function createTranslatorContext(dictionaryDirectory, dictionaryName) {
// Dictionary
@@ -69,31 +68,23 @@ async function createTranslatorContext(dictionaryDirectory, dictionaryName) {
const deinflectionReasons = parseJson(readFileSync(languageTransformDescriptorPath, {encoding: 'utf8'}));
translator.prepare(deinflectionReasons);
- // Assign properties
- const ankiNoteDataCreator = new AnkiNoteDataCreator();
- return {translator, ankiNoteDataCreator};
+ return translator;
}
/**
* @param {string|undefined} htmlFilePath
* @param {string} dictionaryDirectory
* @param {string} dictionaryName
- * @returns {Promise<import('vitest').TestAPI<{window: import('jsdom').DOMWindow, translator: Translator, ankiNoteDataCreator: AnkiNoteDataCreator}>>}
+ * @returns {Promise<import('vitest').TestAPI<{window: import('jsdom').DOMWindow, translator: Translator}>>}
*/
export async function createTranslatorTest(htmlFilePath, dictionaryDirectory, dictionaryName) {
const test = createDomTest(htmlFilePath);
- const {translator, ankiNoteDataCreator} = await createTranslatorContext(dictionaryDirectory, dictionaryName);
- /** @type {import('vitest').TestAPI<{window: import('jsdom').DOMWindow, translator: Translator, ankiNoteDataCreator: AnkiNoteDataCreator}>} */
+ const translator = await createTranslatorContext(dictionaryDirectory, dictionaryName);
+ /** @type {import('vitest').TestAPI<{window: import('jsdom').DOMWindow, translator: Translator}>} */
const result = test.extend({
window: async ({window}, use) => { await use(window); },
// eslint-disable-next-line no-empty-pattern
- translator: async ({}, use) => { await use(translator); },
- ankiNoteDataCreator: async ({window}, use) => {
- // The window property needs to be referenced for it to be initialized.
- // It is needed for DOM access for structured content.
- void window;
- await use(ankiNoteDataCreator);
- }
+ translator: async ({}, use) => { await use(translator); }
});
return result;
}