From 00c5ae79833a641ccc5f7d31b6eea3e91db4cb71 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 31 Jul 2021 12:30:31 -0400 Subject: DictionaryImporterMediaLoader (#1860) * Rename param for consistency * Move media loading functionality into DictionaryImporterMediaLoader * Create test class for media loading * Remove unnecessary Blob/Image/URL functionality --- test/test-database.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test-database.js b/test/test-database.js index 19ac49e2..ac7e825b 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -18,7 +18,7 @@ const path = require('path'); const assert = require('assert'); const {createDictionaryArchive, testMain} = require('../dev/util'); -const {DatabaseVM} = require('../dev/database-vm'); +const {DatabaseVM, DatabaseVMDictionaryImporterMediaLoader} = require('../dev/database-vm'); const vm = new DatabaseVM(); @@ -41,6 +41,12 @@ function createTestDictionaryArchive(dictionary, dictionaryName) { } +function createDictionaryImporter() { + const dictionaryImporterMediaLoader = new DatabaseVMDictionaryImporterMediaLoader(); + return new DictionaryImporter(dictionaryImporterMediaLoader); +} + + function countDictionaryDatabaseEntriesWithTerm(dictionaryDatabaseEntries, term) { return dictionaryDatabaseEntries.reduce((i, v) => (i + (v.term === term ? 1 : 0)), 0); } @@ -125,7 +131,7 @@ async function testDatabase1() { ]; // Setup database - const dictionaryImporter = new DictionaryImporter(); + const dictionaryImporter = createDictionaryImporter(); const dictionaryDatabase = new DictionaryDatabase(); await dictionaryDatabase.prepare(); @@ -775,7 +781,7 @@ async function testDatabase2() { ]); // Setup database - const dictionaryImporter = new DictionaryImporter(); + const dictionaryImporter = createDictionaryImporter(); const dictionaryDatabase = new DictionaryDatabase(); // Error: not prepared @@ -817,7 +823,7 @@ async function testDatabase3() { ]; // Setup database - const dictionaryImporter = new DictionaryImporter(); + const dictionaryImporter = createDictionaryImporter(); const dictionaryDatabase = new DictionaryDatabase(); await dictionaryDatabase.prepare(); -- cgit v1.2.3