diff options
author | Birudo un <cokoryuu@gmail.com> | 2024-03-18 20:29:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 12:29:53 +0000 |
commit | c26680fd7399e8e1fb5e3c10a3f72f592d59e370 (patch) | |
tree | f088a7b06c3ef0440b8aea0d0dff772435a48601 /test | |
parent | 7ee76d708934adeef06479f7757beb22c6c01d14 (diff) |
feat: support skipping already import dictionaries (#769)
Diffstat (limited to 'test')
-rw-r--r-- | test/database.test.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/database.test.js b/test/database.test.js index a930d68d..9d57ecab 100644 --- a/test/database.test.js +++ b/test/database.test.js @@ -121,7 +121,7 @@ describe('Database', () => { // Setup database const dictionaryDatabase = new DictionaryDatabase(); /** @type {import('dictionary-importer').ImportDetails} */ - const detaultImportDetails = {prefixWildcardsSupported: false}; + const defaultImportDetails = {prefixWildcardsSupported: false}; // Database not open await expect.soft(dictionaryDatabase.deleteDictionary(title, 1000, () => {})).rejects.toThrow('Database not open'); @@ -135,17 +135,17 @@ describe('Database', () => { await expect.soft(dictionaryDatabase.findTagForTitle('tag', title)).rejects.toThrow('Database not open'); await expect.soft(dictionaryDatabase.getDictionaryInfo()).rejects.toThrow('Database not open'); await expect.soft(dictionaryDatabase.getDictionaryCounts([...titles.keys()], true)).rejects.toThrow('Database not open'); - await expect.soft(createDictionaryImporter(expect).importDictionary(dictionaryDatabase, testDictionarySource, detaultImportDetails)).rejects.toThrow('Database is not ready'); + await expect.soft(createDictionaryImporter(expect).importDictionary(dictionaryDatabase, testDictionarySource, defaultImportDetails)).rejects.toThrow('Database is not ready'); await dictionaryDatabase.prepare(); // Already prepared await expect.soft(dictionaryDatabase.prepare()).rejects.toThrow('Database already open'); - await createDictionaryImporter(expect).importDictionary(dictionaryDatabase, testDictionarySource, detaultImportDetails); + await createDictionaryImporter(expect).importDictionary(dictionaryDatabase, testDictionarySource, defaultImportDetails); // Dictionary already imported - await expect.soft(createDictionaryImporter(expect).importDictionary(dictionaryDatabase, testDictionarySource, detaultImportDetails)).rejects.toThrow('Dictionary is already imported'); + expect.soft(await createDictionaryImporter(expect).importDictionary(dictionaryDatabase, testDictionarySource, defaultImportDetails)).toEqual({result: null, errors: [new Error('Dictionary Test Dictionary is already imported, skipped it.')]}); await dictionaryDatabase.close(); }); @@ -200,7 +200,11 @@ describe('Database', () => { testDictionarySource, {prefixWildcardsSupported: true} ); - importDictionaryResult.importDate = fakeImportDate; + + if (importDictionaryResult) { + importDictionaryResult.importDate = fakeImportDate; + } + expect.soft(importDictionaryErrors).toStrictEqual([]); expect.soft(importDictionaryResult).toStrictEqual(testData.expectedSummary); expect.soft(progressEvent1).toBe(true); |