Skip to content

Commit

Permalink
Don't expect in write mode
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Dec 21, 2023
1 parent 266fa51 commit af4d974
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/dictionary-data.write.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('Write dictionary data expected data', async ({translator, ankiNoteDataCrea
/** @type {import('translation').FindTermsOptions} */
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 renderResults = mode !== 'simple' ? await getTemplateRenderResults(dictionaryEntries, 'terms', mode, template, null) : null;
const noteDataList = mode !== 'simple' ? dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(ankiNoteDataCreator, dictionaryEntry, mode)) : null;
actualResults1.push({name, originalTextLength, dictionaryEntries});
actualResults2.push({name, noteDataList});
Expand All @@ -75,7 +75,7 @@ test('Write dictionary data expected data', async ({translator, ankiNoteDataCrea
/** @type {import('translation').FindKanjiOptions} */
const options = createFindOptions(dictionaryName, optionsPresets, data.options);
const dictionaryEntries = await translator.findKanji(text, options);
const renderResults = await getTemplateRenderResults(dictionaryEntries, 'kanji', 'split', template, expect);
const renderResults = await getTemplateRenderResults(dictionaryEntries, 'kanji', 'split', template, null);
const noteDataList = dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(ankiNoteDataCreator, dictionaryEntry, 'split'));
actualResults1.push({name, dictionaryEntries});
actualResults2.push({name, noteDataList});
Expand Down
6 changes: 4 additions & 2 deletions test/utilities/anki.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function getFieldMarkers(type) {
* @param {'terms'|'kanji'} type
* @param {import('settings').ResultOutputMode} mode
* @param {string} template
* @param {import('vitest').ExpectStatic} expect
* @param {?import('vitest').ExpectStatic} expect
* @returns {Promise<import('anki').NoteFields[]>}
*/
export async function getTemplateRenderResults(dictionaryEntries, type, mode, template, expect) {
Expand Down Expand Up @@ -179,7 +179,9 @@ export async function getTemplateRenderResults(dictionaryEntries, type, mode, te
for (const error of errors) {
console.error(error);
}
expect(errors.length).toStrictEqual(0);
if (expect !== null) {
expect(errors.length).toStrictEqual(0);
}
results.push(noteFields);
}

Expand Down

0 comments on commit af4d974

Please sign in to comment.