summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-05 12:52:07 -0400
committerGitHub <noreply@github.com>2020-04-05 12:52:07 -0400
commit3684a479c5e12efe63c54e5532a264d157a6816d (patch)
treebb1a3141c37836ab0f8a1cbff5ed781cc41eac39 /test
parent058f626efd6c5d6fae66346d487c10930d769971 (diff)
parent9052ab8ebd5af505f1992bfc001b226202e2f393 (diff)
Merge pull request #424 from toasted-nutbread/dictionary-importer
Dictionary importer
Diffstat (limited to 'test')
-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 dbd67257..c4bfb793 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;
@@ -848,6 +852,7 @@ async function testDatabase2() {
]);
// Setup database
+ const dictionaryImporter = new DictionaryImporter();
const database = new Database();
// Error: not prepared
@@ -863,17 +868,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();
}
@@ -890,6 +895,7 @@ async function testDatabase3() {
];
// Setup database
+ const dictionaryImporter = new DictionaryImporter();
const database = new Database();
await database.prepare();
@@ -899,7 +905,7 @@ async function testDatabase3() {
let error = null;
try {
- await database.importDictionary(testDictionarySource, () => {}, {});
+ await dictionaryImporter.import(database, testDictionarySource, () => {}, {});
} catch (e) {
error = e;
}