diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-28 22:15:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-29 03:15:47 +0000 |
commit | a51ae1533c54162f14785652e9128f90afb86aed (patch) | |
tree | b9deee8cc0378f2fc9cc223b345ef625915b4433 /types | |
parent | 476d7548022ab25cc499f9b3bb712c81a6d3240c (diff) |
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
Diffstat (limited to 'types')
-rw-r--r-- | types/test/database.d.ts | 108 |
1 files changed, 108 insertions, 0 deletions
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 <https://www.gnu.org/licenses/>. + */ + +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<TKey = unknown> = [key: TKey, count: number]; + +export type FindTermsBulkTestCase = { + inputs: { + matchType: MatchType; + termList: string[]; + }[]; + expectedResults: { + total: number; + terms: ItemCount<string>[]; + readings: ItemCount<string>[]; + }; +}; + +export type FindTermsExactBulkTestCase = { + inputs: { + termList: TermExactRequest[]; + }[]; + expectedResults: { + total: number; + terms: ItemCount<string>[]; + readings: ItemCount<string>[]; + }; +}; + +export type FindTermsBySequenceBulkTestCase = { + inputs: { + sequenceList: number[]; + }[]; + expectedResults: { + total: number; + terms: ItemCount<string>[]; + readings: ItemCount<string>[]; + }; +}; + +export type FindTermMetaBulkTestCase = { + inputs: { + termList: string[]; + }[]; + expectedResults: { + total: number; + modes: ItemCount<TermMetaType>[]; + }; +}; + +export type FindKanjiBulkTestCase = { + inputs: { + kanjiList: string[]; + }[]; + expectedResults: { + total: number; + kanji: ItemCount<string>[]; + }; +}; + +export type FindKanjiMetaBulkTestCase = { + inputs: { + kanjiList: string[]; + }[]; + expectedResults: { + total: number; + modes: ItemCount<KanjiMetaType>[]; + }; +}; + +export type FindTagForTitleTestCase = { + inputs: { + name: string; + }[]; + expectedResults: { + value: Tag | null; + }; +}; |