From a51ae1533c54162f14785652e9128f90afb86aed Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 28 Dec 2023 22:15:47 -0500 Subject: Database test updates (#461) * Initial changes * Move test * Disable async * Add createCustomDataTest * Move test case data to JSON file * Update tests * Cleanup * Simplify * Add dedicated test for database clearing * Remove previous clear testing * Remove unused test function * Update values --- types/test/database.d.ts | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 types/test/database.d.ts (limited to 'types') diff --git a/types/test/database.d.ts b/types/test/database.d.ts new file mode 100644 index 00000000..c24723e1 --- /dev/null +++ b/types/test/database.d.ts @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2023 Yomitan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import type {Summary} from '../ext/dictionary-importer'; +import type {Tag, MatchType, TermMetaType, KanjiMetaType, TermExactRequest, DictionaryCounts} from '../ext/dictionary-database'; + +export type DatabaseTestData = { + expectedSummary: Summary; + expectedCounts: DictionaryCounts; + tests: { + findTermsBulk: FindTermsBulkTestCase[]; + findTermsExactBulk: FindTermsExactBulkTestCase[]; + findTermsBySequenceBulk: FindTermsBySequenceBulkTestCase[]; + findTermMetaBulk: FindTermMetaBulkTestCase[]; + findKanjiBulk: FindKanjiBulkTestCase[]; + findKanjiMetaBulk: FindKanjiMetaBulkTestCase[]; + findTagForTitle: FindTagForTitleTestCase[]; + }; +}; + +export type ItemCount = [key: TKey, count: number]; + +export type FindTermsBulkTestCase = { + inputs: { + matchType: MatchType; + termList: string[]; + }[]; + expectedResults: { + total: number; + terms: ItemCount[]; + readings: ItemCount[]; + }; +}; + +export type FindTermsExactBulkTestCase = { + inputs: { + termList: TermExactRequest[]; + }[]; + expectedResults: { + total: number; + terms: ItemCount[]; + readings: ItemCount[]; + }; +}; + +export type FindTermsBySequenceBulkTestCase = { + inputs: { + sequenceList: number[]; + }[]; + expectedResults: { + total: number; + terms: ItemCount[]; + readings: ItemCount[]; + }; +}; + +export type FindTermMetaBulkTestCase = { + inputs: { + termList: string[]; + }[]; + expectedResults: { + total: number; + modes: ItemCount[]; + }; +}; + +export type FindKanjiBulkTestCase = { + inputs: { + kanjiList: string[]; + }[]; + expectedResults: { + total: number; + kanji: ItemCount[]; + }; +}; + +export type FindKanjiMetaBulkTestCase = { + inputs: { + kanjiList: string[]; + }[]; + expectedResults: { + total: number; + modes: ItemCount[]; + }; +}; + +export type FindTagForTitleTestCase = { + inputs: { + name: string; + }[]; + expectedResults: { + value: Tag | null; + }; +}; -- cgit v1.2.3