diff options
Diffstat (limited to 'test/utilities/anki.js')
-rw-r--r-- | test/utilities/anki.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/utilities/anki.js b/test/utilities/anki.js index 6471015a..ed7b6c60 100644 --- a/test/utilities/anki.js +++ b/test/utilities/anki.js @@ -36,11 +36,16 @@ function createTestFields(type) { /** * @param {import('dictionary').DictionaryEntry} dictionaryEntry * @param {import('settings').ResultOutputMode} mode + * @param {string} styles * @returns {import('anki-templates').NoteData} * @throws {Error} */ -export function createTestAnkiNoteData(dictionaryEntry, mode) { +export function createTestAnkiNoteData(dictionaryEntry, mode, styles = '') { const marker = '{marker}'; + const dictionaryStylesMap = new Map(); + if (styles !== '') { + dictionaryStylesMap.set('Test Dictionary 2', styles); + } /** @type {import('anki-templates-internal').CreateDetails} */ const data = { dictionaryEntry, @@ -56,6 +61,7 @@ export function createTestAnkiNoteData(dictionaryEntry, mode) { fullQuery: 'fullQuery', }, media: {}, + dictionaryStylesMap, }; return createAnkiNoteData(marker, data); } @@ -65,9 +71,10 @@ export function createTestAnkiNoteData(dictionaryEntry, mode) { * @param {import('settings').ResultOutputMode} mode * @param {string} template * @param {?import('vitest').ExpectStatic} expect + * @param {string} styles * @returns {Promise<import('anki').NoteFields[]>} */ -export async function getTemplateRenderResults(dictionaryEntries, mode, template, expect) { +export async function getTemplateRenderResults(dictionaryEntries, mode, template, expect, styles = '') { const ankiTemplateRenderer = new AnkiTemplateRenderer(); await ankiTemplateRenderer.prepare(); const clozePrefix = 'cloze-prefix'; @@ -97,6 +104,10 @@ export async function getTemplateRenderResults(dictionaryEntries, mode, template query: 'query', fullQuery: 'fullQuery', }; + const dictionaryStylesMap = new Map(); + if (styles) { + dictionaryStylesMap.set('Test Dictionary 2', styles); + } /** @type {import('anki-note-builder').CreateNoteDetails} */ const details = { dictionaryEntry, @@ -114,6 +125,7 @@ export async function getTemplateRenderResults(dictionaryEntries, mode, template compactTags: false, requirements: [], mediaOptions: null, + dictionaryStylesMap, }; const {note: {fields: noteFields}, errors} = await ankiNoteBuilder.createNote(details); for (const error of errors) { |