From 1599ec1f15ef02e5687fbfc4ad15dd55b019ee70 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 31 Aug 2021 21:42:18 -0400 Subject: Fix dictionary import total progress (#1921) * Fix incorrect total count for final step of dictionary import * Update tests to validate progress args --- ext/js/language/dictionary-importer.js | 2 +- test/test-database.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index cd1b796b..98cddf76 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -126,7 +126,7 @@ class DictionaryImporter { const {media} = await this._resolveAsyncRequirements(requirements, archive); // Add dictionary descriptor - this._progressNextStep(termList.length + termMetaList.length + kanjiList.length + kanjiMetaList.length + tagList.length); + this._progressNextStep(termList.length + termMetaList.length + kanjiList.length + kanjiMetaList.length + tagList.length + media.length); const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported}); dictionaryDatabase.bulkAdd('dictionaries', [summary], 0, 1); diff --git a/test/test-database.js b/test/test-database.js index 21c653be..e855f07f 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -43,7 +43,14 @@ function createTestDictionaryArchive(dictionary, dictionaryName) { function createDictionaryImporter(onProgress) { const dictionaryImporterMediaLoader = new DatabaseVMDictionaryImporterMediaLoader(); - return new DictionaryImporter(dictionaryImporterMediaLoader, onProgress); + return new DictionaryImporter(dictionaryImporterMediaLoader, (...args) => { + const {stepIndex, stepCount, index, count} = args[0]; + assert.ok(stepIndex < stepCount); + assert.ok(index <= count); + if (typeof onProgress === 'function') { + onProgress(...args); + } + }); } -- cgit v1.2.3