aboutsummaryrefslogtreecommitdiff
path: root/test/test-anki-note-builder.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-anki-note-builder.js')
-rw-r--r--test/test-anki-note-builder.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js
index af9cd061..c7d91325 100644
--- a/test/test-anki-note-builder.js
+++ b/test/test-anki-note-builder.js
@@ -128,7 +128,7 @@ async function createVM() {
}
vm.set({TemplateRendererProxy});
- return {vm, AnkiNoteBuilder};
+ return {vm, AnkiNoteBuilder, JapaneseUtil};
}
function getFieldMarkers(type) {
@@ -160,6 +160,7 @@ function getFieldMarkers(type) {
'search-query',
'selection-text',
'sentence',
+ 'sentence-furigana',
'tags',
'url'
];
@@ -180,6 +181,7 @@ function getFieldMarkers(type) {
'search-query',
'selection-text',
'sentence',
+ 'sentence-furigana',
'stroke-count',
'tags',
'url'
@@ -189,13 +191,14 @@ function getFieldMarkers(type) {
}
}
-async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNoteBuilder, write) {
+async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNoteBuilder, JapaneseUtil, write) {
const markers = getFieldMarkers(type);
const fields = [];
for (const marker of markers) {
fields.push([marker, `{${marker}}`]);
}
+ const japaneseUtil = new JapaneseUtil(null);
const clozePrefix = 'cloze-prefix';
const clozeSuffix = 'cloze-suffix';
const results = [];
@@ -211,7 +214,7 @@ async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNot
}
break;
}
- const ankiNoteBuilder = new AnkiNoteBuilder();
+ const ankiNoteBuilder = new AnkiNoteBuilder({japaneseUtil});
const context = {
url: 'url:',
sentence: {
@@ -250,7 +253,7 @@ async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNot
async function main() {
const write = (process.argv[2] === '--write');
- const {vm, AnkiNoteBuilder} = await createVM();
+ const {vm, AnkiNoteBuilder, JapaneseUtil} = await createVM();
const testInputsFilePath = path.join(__dirname, 'data', 'translator-test-inputs.json');
const {optionsPresets, tests} = JSON.parse(fs.readFileSync(testInputsFilePath, {encoding: 'utf8'}));
@@ -270,7 +273,7 @@ async function main() {
const {name, mode, text} = test;
const options = vm.buildOptions(optionsPresets, test.options);
const {dictionaryEntries} = clone(await vm.translator.findTerms(mode, text, options));
- const results = mode !== 'simple' ? clone(await getRenderResults(dictionaryEntries, 'terms', mode, template, AnkiNoteBuilder, write)) : null;
+ const results = mode !== 'simple' ? clone(await getRenderResults(dictionaryEntries, 'terms', mode, template, AnkiNoteBuilder, JapaneseUtil, write)) : null;
actualResults1.push({name, results});
if (!write) {
assert.deepStrictEqual(results, expected1.results);
@@ -282,7 +285,7 @@ async function main() {
const {name, text} = test;
const options = vm.buildOptions(optionsPresets, test.options);
const dictionaryEntries = clone(await vm.translator.findKanji(text, options));
- const results = clone(await getRenderResults(dictionaryEntries, 'kanji', null, template, AnkiNoteBuilder, write));
+ const results = clone(await getRenderResults(dictionaryEntries, 'kanji', null, template, AnkiNoteBuilder, JapaneseUtil, write));
actualResults1.push({name, results});
if (!write) {
assert.deepStrictEqual(results, expected1.results);