aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test-anki-note-builder.js2
-rw-r--r--test/test-database.js80
-rw-r--r--test/test-japanese.js16
-rw-r--r--test/test-options-util.js4
4 files changed, 51 insertions, 51 deletions
diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js
index 152a8739..d8fd558e 100644
--- a/test/test-anki-note-builder.js
+++ b/test/test-anki-note-builder.js
@@ -171,7 +171,7 @@ async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNot
};
const errors = [];
const noteFields = (await ankiNoteBuilder.createNote({
- definition: dictionaryEntry,
+ dictionaryEntry,
mode: null,
context,
template,
diff --git a/test/test-database.js b/test/test-database.js
index c36b5b46..3051925d 100644
--- a/test/test-database.js
+++ b/test/test-database.js
@@ -41,12 +41,12 @@ function createTestDictionaryArchive(dictionary, dictionaryName) {
}
-function countTermsWithExpression(terms, expression) {
- return terms.reduce((i, v) => (i + (v.expression === expression ? 1 : 0)), 0);
+function countDictionaryDatabaseEntriesWithTerm(dictionaryDatabaseEntries, term) {
+ return dictionaryDatabaseEntries.reduce((i, v) => (i + (v.term === term ? 1 : 0)), 0);
}
-function countTermsWithReading(terms, reading) {
- return terms.reduce((i, v) => (i + (v.reading === reading ? 1 : 0)), 0);
+function countDictionaryDatabaseEntriesWithReading(dictionaryDatabaseEntries, reading) {
+ return dictionaryDatabaseEntries.reduce((i, v) => (i + (v.reading === reading ? 1 : 0)), 0);
}
function countMetasWithMode(metas, mode) {
@@ -212,7 +212,7 @@ async function testFindTermsBulkTest1(database, titles) {
],
expectedResults: {
total: 32,
- expressions: [
+ terms: [
['打', 2],
['打つ', 17],
['打ち込む', 13]
@@ -236,7 +236,7 @@ async function testFindTermsBulkTest1(database, titles) {
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
},
@@ -249,7 +249,7 @@ async function testFindTermsBulkTest1(database, titles) {
],
expectedResults: {
total: 13,
- expressions: [
+ terms: [
['打ち込む', 13]
],
readings: [
@@ -267,7 +267,7 @@ async function testFindTermsBulkTest1(database, titles) {
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
}
@@ -277,11 +277,11 @@ async function testFindTermsBulkTest1(database, titles) {
for (const {termList, wildcard} of inputs) {
const results = await database.findTermsBulk(termList, titles, wildcard);
assert.strictEqual(results.length, expectedResults.total);
- for (const [expression, count] of expectedResults.expressions) {
- assert.strictEqual(countTermsWithExpression(results, expression), count);
+ for (const [term, count] of expectedResults.terms) {
+ assert.strictEqual(countDictionaryDatabaseEntriesWithTerm(results, term), count);
}
for (const [reading, count] of expectedResults.readings) {
- assert.strictEqual(countTermsWithReading(results, reading), count);
+ assert.strictEqual(countDictionaryDatabaseEntriesWithReading(results, reading), count);
}
}
}
@@ -293,15 +293,15 @@ async function testTindTermsExactBulk1(database, titles) {
inputs: [
{
termList: [
- {expression: '打', reading: 'だ'},
- {expression: '打つ', reading: 'うつ'},
- {expression: '打ち込む', reading: 'うちこむ'}
+ {term: '打', reading: 'だ'},
+ {term: '打つ', reading: 'うつ'},
+ {term: '打ち込む', reading: 'うちこむ'}
]
}
],
expectedResults: {
total: 25,
- expressions: [
+ terms: [
['打', 1],
['打つ', 15],
['打ち込む', 9]
@@ -317,15 +317,15 @@ async function testTindTermsExactBulk1(database, titles) {
inputs: [
{
termList: [
- {expression: '打', reading: 'だ?'},
- {expression: '打つ', reading: 'うつ?'},
- {expression: '打ち込む', reading: 'うちこむ?'}
+ {term: '打', reading: 'だ?'},
+ {term: '打つ', reading: 'うつ?'},
+ {term: '打ち込む', reading: 'うちこむ?'}
]
}
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
},
@@ -333,14 +333,14 @@ async function testTindTermsExactBulk1(database, titles) {
inputs: [
{
termList: [
- {expression: '打つ', reading: 'うつ'},
- {expression: '打つ', reading: 'ぶつ'}
+ {term: '打つ', reading: 'うつ'},
+ {term: '打つ', reading: 'ぶつ'}
]
}
],
expectedResults: {
total: 17,
- expressions: [
+ terms: [
['打つ', 17]
],
readings: [
@@ -353,13 +353,13 @@ async function testTindTermsExactBulk1(database, titles) {
inputs: [
{
termList: [
- {expression: '打つ', reading: 'うちこむ'}
+ {term: '打つ', reading: 'うちこむ'}
]
}
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
},
@@ -371,7 +371,7 @@ async function testTindTermsExactBulk1(database, titles) {
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
}
@@ -381,11 +381,11 @@ async function testTindTermsExactBulk1(database, titles) {
for (const {termList} of inputs) {
const results = await database.findTermsExactBulk(termList, titles);
assert.strictEqual(results.length, expectedResults.total);
- for (const [expression, count] of expectedResults.expressions) {
- assert.strictEqual(countTermsWithExpression(results, expression), count);
+ for (const [term, count] of expectedResults.terms) {
+ assert.strictEqual(countDictionaryDatabaseEntriesWithTerm(results, term), count);
}
for (const [reading, count] of expectedResults.readings) {
- assert.strictEqual(countTermsWithReading(results, reading), count);
+ assert.strictEqual(countDictionaryDatabaseEntriesWithReading(results, reading), count);
}
}
}
@@ -401,7 +401,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 33,
- expressions: [
+ terms: [
['打', 2],
['打つ', 17],
['打ち込む', 13],
@@ -426,7 +426,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 1,
- expressions: [
+ terms: [
['打', 1]
],
readings: [
@@ -442,7 +442,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 1,
- expressions: [
+ terms: [
['打', 1]
],
readings: [
@@ -458,7 +458,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 17,
- expressions: [
+ terms: [
['打つ', 17]
],
readings: [
@@ -475,7 +475,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 13,
- expressions: [
+ terms: [
['打ち込む', 13]
],
readings: [
@@ -492,7 +492,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 1,
- expressions: [
+ terms: [
['画像', 1]
],
readings: [
@@ -508,7 +508,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
},
@@ -520,7 +520,7 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
],
expectedResults: {
total: 0,
- expressions: [],
+ terms: [],
readings: []
}
}
@@ -530,11 +530,11 @@ async function testFindTermsBySequenceBulk1(database, mainDictionary) {
for (const {sequenceList} of inputs) {
const results = await database.findTermsBySequenceBulk(sequenceList.map((query) => ({query, dictionary: mainDictionary})));
assert.strictEqual(results.length, expectedResults.total);
- for (const [expression, count] of expectedResults.expressions) {
- assert.strictEqual(countTermsWithExpression(results, expression), count);
+ for (const [term, count] of expectedResults.terms) {
+ assert.strictEqual(countDictionaryDatabaseEntriesWithTerm(results, term), count);
}
for (const [reading, count] of expectedResults.readings) {
- assert.strictEqual(countTermsWithReading(results, reading), count);
+ assert.strictEqual(countDictionaryDatabaseEntriesWithReading(results, reading), count);
}
}
}
@@ -781,7 +781,7 @@ async function testDatabase2() {
// Error: not prepared
await assert.rejects(async () => await dictionaryDatabase.deleteDictionary(title, {rate: 1000}, () => {}));
await assert.rejects(async () => await dictionaryDatabase.findTermsBulk(['?'], titles, null));
- await assert.rejects(async () => await dictionaryDatabase.findTermsExactBulk([{expression: '?', reading: '?'}], titles));
+ await assert.rejects(async () => await dictionaryDatabase.findTermsExactBulk([{term: '?', reading: '?'}], titles));
await assert.rejects(async () => await dictionaryDatabase.findTermsBySequenceBulk([{query: 1, dictionary: title}]));
await assert.rejects(async () => await dictionaryDatabase.findTermMetaBulk(['?'], titles));
await assert.rejects(async () => await dictionaryDatabase.findTermMetaBulk(['?'], titles));
diff --git a/test/test-japanese.js b/test/test-japanese.js
index 978f4b9c..2772e984 100644
--- a/test/test-japanese.js
+++ b/test/test-japanese.js
@@ -199,7 +199,7 @@ function testConvertReading() {
[['ありがとう', '', 'none'], ''],
[['ありがとう', '', 'default'], ''],
- // Cases with falsy readings and kanji expressions
+ // Cases with falsy readings and kanji terms
[['有り難う', '', 'hiragana'], ''],
[['有り難う', '', 'katakana'], ''],
@@ -208,8 +208,8 @@ function testConvertReading() {
[['有り難う', '', 'default'], '']
];
- for (const [[expression, reading, readingMode], expected] of data) {
- assert.strictEqual(jp.convertReading(expression, reading, readingMode), expected);
+ for (const [[term, reading, readingMode], expected] of data) {
+ assert.strictEqual(jp.convertReading(term, reading, readingMode), expected);
}
}
@@ -708,7 +708,7 @@ function testDistributeFurigana() {
{text: 'る', furigana: 'ル'}
]
],
- // Reading starts with expression, but has remainder characters
+ // Reading starts with term, but has remainder characters
[
['シック', 'シック・ビルしょうこうぐん'],
[
@@ -717,8 +717,8 @@ function testDistributeFurigana() {
]
];
- for (const [[expression, reading], expected] of data) {
- const actual = jp.distributeFurigana(expression, reading);
+ for (const [[term, reading], expected] of data) {
+ const actual = jp.distributeFurigana(term, reading);
vm.assert.deepStrictEqual(actual, expected);
}
}
@@ -766,8 +766,8 @@ function testDistributeFuriganaInflected() {
]
];
- for (const [[expression, reading, source], expected] of data) {
- const actual = jp.distributeFuriganaInflected(expression, reading, source);
+ for (const [[term, reading, source], expected] of data) {
+ const actual = jp.distributeFuriganaInflected(term, reading, source);
vm.assert.deepStrictEqual(actual, expected);
}
}
diff --git a/test/test-options-util.js b/test/test-options-util.js
index cd948c91..4194861a 100644
--- a/test/test-options-util.js
+++ b/test/test-options-util.js
@@ -107,7 +107,7 @@ function createProfileOptionsTestData1() {
sources: ['jpod101'],
volume: 100,
autoPlay: false,
- customSourceUrl: '',
+ customSourceUrl: 'http://localhost/audio.mp3?term={expression}&reading={reading}',
textToSpeechVoice: ''
},
scanning: {
@@ -309,7 +309,7 @@ function createProfileOptionsUpdatedTestData1() {
sources: ['jpod101'],
volume: 100,
autoPlay: false,
- customSourceUrl: '',
+ customSourceUrl: 'http://localhost/audio.mp3?term={term}&reading={reading}',
customSourceType: 'audio',
textToSpeechVoice: ''
},