diff options
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/translator-test.js | 21 |
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; } |