aboutsummaryrefslogtreecommitdiff
path: root/test/translator.test.js
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-12-06 03:53:16 +0000
committerGitHub <noreply@github.com>2023-12-06 03:53:16 +0000
commitbd5bc1a5db29903bc098995cd9262c4576bf76af (patch)
treec9214189e0214480fcf6539ad1c6327aef6cbd1c /test/translator.test.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
parent23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff)
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'test/translator.test.js')
-rw-r--r--test/translator.test.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/test/translator.test.js b/test/translator.test.js
index 7a827d39..3db560a7 100644
--- a/test/translator.test.js
+++ b/test/translator.test.js
@@ -28,6 +28,7 @@ vi.stubGlobal('IDBKeyRange', IDBKeyRange);
const dirname = path.dirname(fileURLToPath(import.meta.url));
+/** */
async function main() {
const translatorVM = new TranslatorVM();
const dictionaryDirectory = path.join(dirname, 'data', 'dictionaries', 'valid-dictionary1');
@@ -53,6 +54,7 @@ async function main() {
case 'findTerms':
{
const {name, mode, text} = t;
+ /** @type {import('translation').FindTermsOptions} */
const options = translatorVM.buildOptions(optionsPresets, t.options);
const {dictionaryEntries, originalTextLength} = structuredClone(await translatorVM.translator.findTerms(mode, text, options));
const noteDataList = mode !== 'simple' ? structuredClone(dictionaryEntries.map((dictionaryEntry) => translatorVM.createTestAnkiNoteData(structuredClone(dictionaryEntry), mode))) : null;
@@ -66,9 +68,10 @@ async function main() {
case 'findKanji':
{
const {name, text} = t;
+ /** @type {import('translation').FindKanjiOptions} */
const options = translatorVM.buildOptions(optionsPresets, t.options);
const dictionaryEntries = structuredClone(await translatorVM.translator.findKanji(text, options));
- const noteDataList = structuredClone(dictionaryEntries.map((dictionaryEntry) => translatorVM.createTestAnkiNoteData(structuredClone(dictionaryEntry), null)));
+ const noteDataList = structuredClone(dictionaryEntries.map((dictionaryEntry) => translatorVM.createTestAnkiNoteData(structuredClone(dictionaryEntry), 'split')));
actualResults1.push({name, dictionaryEntries});
actualResults2.push({name, noteDataList});
expect(dictionaryEntries).toStrictEqual(expected1.dictionaryEntries);