summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-31 18:08:51 -0400
committerGitHub <noreply@github.com>2021-07-31 18:08:51 -0400
commit01c5c5c04bd9234c64d6f57ee0ea65b0f478a1b7 (patch)
treef262b7042bd56fc9b72efb7b42d97341efd50df9 /test
parent1d6e437fb284a591fc1b7f4aec87bbc7cde5367f (diff)
Dictionary importer refactoring (#1867)
* Remove map of schemas * Don't reuse dictionary importer instances * Refactor * Update how progress callback is used
Diffstat (limited to 'test')
-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;
}