summaryrefslogtreecommitdiff
path: root/test/test-database.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-30 20:51:20 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-30 20:51:20 -0400
commit9052ab8ebd5af505f1992bfc001b226202e2f393 (patch)
tree4c882f0d4e84cc2874ce534af5bf2de802cfba6d /test/test-database.js
parent02f7763f004790a432302637586a876291e32f61 (diff)
Move dictionary import functionality into a new class
Diffstat (limited to 'test/test-database.js')
-rw-r--r--test/test-database.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/test-database.js b/test/test-database.js
index 833aa75d..c3402b73 100644
--- a/test/test-database.js
+++ b/test/test-database.js
@@ -107,8 +107,10 @@ vm.execute([
'bg/js/dictionary.js',
'mixed/js/core.js',
'bg/js/request.js',
+ 'bg/js/dictionary-importer.js',
'bg/js/database.js'
]);
+const DictionaryImporter = vm.get('DictionaryImporter');
const Database = vm.get('Database');
@@ -196,6 +198,7 @@ async function testDatabase1() {
];
// Setup database
+ const dictionaryImporter = new DictionaryImporter();
const database = new Database();
await database.prepare();
@@ -210,7 +213,8 @@ async function testDatabase1() {
// Import data
let progressEvent = false;
- const {result, errors} = await database.importDictionary(
+ const {result, errors} = await dictionaryImporter.import(
+ database,
testDictionarySource,
() => {
progressEvent = true;
@@ -847,6 +851,7 @@ async function testDatabase2() {
]);
// Setup database
+ const dictionaryImporter = new DictionaryImporter();
const database = new Database();
// Error: not prepared
@@ -862,17 +867,17 @@ async function testDatabase2() {
await assert.rejects(async () => await database.findTagForTitle('tag', title));
await assert.rejects(async () => await database.getDictionaryInfo());
await assert.rejects(async () => await database.getDictionaryCounts(titles, true));
- await assert.rejects(async () => await database.importDictionary(testDictionarySource, () => {}, {}));
+ await assert.rejects(async () => await dictionaryImporter.import(database, testDictionarySource, () => {}, {}));
await database.prepare();
// Error: already prepared
await assert.rejects(async () => await database.prepare());
- await database.importDictionary(testDictionarySource, () => {}, {});
+ await dictionaryImporter.import(database, testDictionarySource, () => {}, {});
// Error: dictionary already imported
- await assert.rejects(async () => await database.importDictionary(testDictionarySource, () => {}, {}));
+ await assert.rejects(async () => await dictionaryImporter.import(database, testDictionarySource, () => {}, {}));
await database.close();
}
@@ -889,6 +894,7 @@ async function testDatabase3() {
];
// Setup database
+ const dictionaryImporter = new DictionaryImporter();
const database = new Database();
await database.prepare();
@@ -898,7 +904,7 @@ async function testDatabase3() {
let error = null;
try {
- await database.importDictionary(testDictionarySource, () => {}, {});
+ await dictionaryImporter.import(database, testDictionarySource, () => {}, {});
} catch (e) {
error = e;
}