aboutsummaryrefslogtreecommitdiff
path: root/test/test-translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-25 19:55:31 -0400
committerGitHub <noreply@github.com>2021-03-25 19:55:31 -0400
commit4be5c8fd9f7860e701d0b7d3c8c0ee934bc60a4f (patch)
treedcd78316afdf00bbb67d3d1aa6555a9c8ea3efec /test/test-translator.js
parente7035dcff41d94f20c0bc8865d413412afc7c229 (diff)
Refactor Translator and dictionary entry format (#1553)
* Update test data * Move translator.js * Create new version of Translator * Update Backend * Update DictionaryDataUtil * Update DisplayGenerator * Create AnkiNoteDataCreator * Replace AnkiNoteData with AnkiNoteDataCreator * Update tests * Remove AnkiNoteData * Update test data * Remove translator-old.js * Add TypeScript interface definitions for the new translator data format
Diffstat (limited to 'test/test-translator.js')
-rw-r--r--test/test-translator.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/test-translator.js b/test/test-translator.js
index e5dae5d8..49dc7c06 100644
--- a/test/test-translator.js
+++ b/test/test-translator.js
@@ -54,13 +54,13 @@ async function main() {
{
const {name, mode, text} = test;
const options = translatorVM.buildOptions(optionsPresets, test.options);
- const [definitions, length] = clone(await translatorVM.translator.findTerms(mode, text, options));
- const noteDataList = mode !== 'simple' ? clone(definitions.map((definition) => translatorVM.createTestAnkiNoteData(clone(definition), mode))) : null;
- actualResults1.push({name, length, definitions});
+ const {dictionaryEntries, originalTextLength} = clone(await translatorVM.translator.findTerms(mode, text, options));
+ const noteDataList = mode !== 'simple' ? clone(dictionaryEntries.map((dictionaryEntry) => translatorVM.createTestAnkiNoteData(clone(dictionaryEntry), mode))) : null;
+ actualResults1.push({name, originalTextLength, dictionaryEntries});
actualResults2.push({name, noteDataList});
if (!write) {
- assert.deepStrictEqual(length, expected1.length);
- assert.deepStrictEqual(definitions, expected1.definitions);
+ assert.deepStrictEqual(originalTextLength, expected1.originalTextLength);
+ assert.deepStrictEqual(dictionaryEntries, expected1.dictionaryEntries);
assert.deepStrictEqual(noteDataList, expected2.noteDataList);
}
}
@@ -69,12 +69,12 @@ async function main() {
{
const {name, text} = test;
const options = translatorVM.buildOptions(optionsPresets, test.options);
- const definitions = clone(await translatorVM.translator.findKanji(text, options));
- const noteDataList = clone(definitions.map((definition) => translatorVM.createTestAnkiNoteData(clone(definition), null)));
- actualResults1.push({name, definitions});
+ const dictionaryEntries = clone(await translatorVM.translator.findKanji(text, options));
+ const noteDataList = clone(dictionaryEntries.map((dictionaryEntry) => translatorVM.createTestAnkiNoteData(clone(dictionaryEntry), null)));
+ actualResults1.push({name, dictionaryEntries});
actualResults2.push({name, noteDataList});
if (!write) {
- assert.deepStrictEqual(definitions, expected1.definitions);
+ assert.deepStrictEqual(dictionaryEntries, expected1.dictionaryEntries);
assert.deepStrictEqual(noteDataList, expected2.noteDataList);
}
}