aboutsummaryrefslogtreecommitdiff
path: root/test/dictionary-data.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/dictionary-data.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/dictionary-data.test.js')
-rw-r--r--test/dictionary-data.test.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/dictionary-data.test.js b/test/dictionary-data.test.js
index 438e1e97..9f8ba6f0 100644
--- a/test/dictionary-data.test.js
+++ b/test/dictionary-data.test.js
@@ -53,7 +53,10 @@ describe('Dictionary data', () => {
expected3: expectedResults3[i]
}));
describe.each(testCases)('Test %#: $data.name', ({data, expected1, expected2, expected3}) => {
- test('Test', async ({translator, ankiNoteDataCreator, expect}) => {
+ test('Test', async ({window, translator, expect}) => {
+ // The window property needs to be referenced for it to be initialized.
+ // It is needed for DOM access for structured content.
+ void window;
switch (data.func) {
case 'findTerms':
{
@@ -62,7 +65,7 @@ describe('Dictionary data', () => {
const options = createFindOptions(dictionaryName, optionsPresets, data.options);
const {dictionaryEntries, originalTextLength} = await translator.findTerms(mode, text, options);
const renderResults = mode !== 'simple' ? await getTemplateRenderResults(dictionaryEntries, 'terms', mode, template, expect) : null;
- const noteDataList = mode !== 'simple' ? dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(ankiNoteDataCreator, dictionaryEntry, mode)) : null;
+ const noteDataList = mode !== 'simple' ? dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(dictionaryEntry, mode)) : null;
expect.soft(originalTextLength).toStrictEqual(expected1.originalTextLength);
expect.soft(dictionaryEntries).toStrictEqual(expected1.dictionaryEntries);
expect.soft(noteDataList).toEqual(expected2.noteDataList);
@@ -76,7 +79,7 @@ describe('Dictionary data', () => {
const options = createFindOptions(dictionaryName, optionsPresets, data.options);
const dictionaryEntries = await translator.findKanji(text, options);
const renderResults = await getTemplateRenderResults(dictionaryEntries, 'kanji', 'split', template, expect);
- const noteDataList = dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(ankiNoteDataCreator, dictionaryEntry, 'split'));
+ const noteDataList = dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(dictionaryEntry, 'split'));
expect.soft(dictionaryEntries).toStrictEqual(expected1.dictionaryEntries);
expect.soft(noteDataList).toEqual(expected2.noteDataList);
expect.soft(renderResults).toStrictEqual(expected3.results);