aboutsummaryrefslogtreecommitdiff
path: root/test/test-database.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-database.js')
-rw-r--r--test/test-database.js21
1 files changed, 8 insertions, 13 deletions
diff --git a/test/test-database.js b/test/test-database.js
index ac7e825b..21c653be 100644
--- a/test/test-database.js
+++ b/test/test-database.js
@@ -41,9 +41,9 @@ function createTestDictionaryArchive(dictionary, dictionaryName) {
}
-function createDictionaryImporter() {
+function createDictionaryImporter(onProgress) {
const dictionaryImporterMediaLoader = new DatabaseVMDictionaryImporterMediaLoader();
- return new DictionaryImporter(dictionaryImporterMediaLoader);
+ return new DictionaryImporter(dictionaryImporterMediaLoader, onProgress);
}
@@ -131,7 +131,6 @@ async function testDatabase1() {
];
// Setup database
- const dictionaryImporter = createDictionaryImporter();
const dictionaryDatabase = new DictionaryDatabase();
await dictionaryDatabase.prepare();
@@ -146,13 +145,11 @@ async function testDatabase1() {
// Import data
let progressEvent = false;
+ const dictionaryImporter = createDictionaryImporter(() => { progressEvent = true; });
const {result, errors} = await dictionaryImporter.importDictionary(
dictionaryDatabase,
testDictionarySource,
- {prefixWildcardsSupported: true},
- () => {
- progressEvent = true;
- }
+ {prefixWildcardsSupported: true}
);
vm.assert.deepStrictEqual(errors, []);
vm.assert.deepStrictEqual(result, expectedSummary);
@@ -781,7 +778,6 @@ async function testDatabase2() {
]);
// Setup database
- const dictionaryImporter = createDictionaryImporter();
const dictionaryDatabase = new DictionaryDatabase();
// Error: not prepared
@@ -796,17 +792,17 @@ async function testDatabase2() {
await assert.rejects(async () => await dictionaryDatabase.findTagForTitle('tag', title));
await assert.rejects(async () => await dictionaryDatabase.getDictionaryInfo());
await assert.rejects(async () => await dictionaryDatabase.getDictionaryCounts(titles, true));
- await assert.rejects(async () => await dictionaryImporter.importDictionary(dictionaryDatabase, testDictionarySource, {}, () => {}));
+ await assert.rejects(async () => await createDictionaryImporter().importDictionary(dictionaryDatabase, testDictionarySource, {}));
await dictionaryDatabase.prepare();
// Error: already prepared
await assert.rejects(async () => await dictionaryDatabase.prepare());
- await dictionaryImporter.importDictionary(dictionaryDatabase, testDictionarySource, {}, () => {});
+ await createDictionaryImporter().importDictionary(dictionaryDatabase, testDictionarySource, {});
// Error: dictionary already imported
- await assert.rejects(async () => await dictionaryImporter.importDictionary(dictionaryDatabase, testDictionarySource, {}, () => {}));
+ await assert.rejects(async () => await createDictionaryImporter().importDictionary(dictionaryDatabase, testDictionarySource, {}));
await dictionaryDatabase.close();
}
@@ -823,7 +819,6 @@ async function testDatabase3() {
];
// Setup database
- const dictionaryImporter = createDictionaryImporter();
const dictionaryDatabase = new DictionaryDatabase();
await dictionaryDatabase.prepare();
@@ -833,7 +828,7 @@ async function testDatabase3() {
let error = null;
try {
- await dictionaryImporter.importDictionary(dictionaryDatabase, testDictionarySource, {}, () => {});
+ await createDictionaryImporter().importDictionary(dictionaryDatabase, testDictionarySource, {});
} catch (e) {
error = e;
}