diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-19 00:33:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 05:33:38 +0000 |
commit | 1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch) | |
tree | 305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /types/test | |
parent | 5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff) |
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer
* Fix any type
* Add readResponseJson
* Use readResponseJson
* Additional updates
* Rename files
* Add types
Diffstat (limited to 'types/test')
-rw-r--r-- | types/test/dom-text-scanner.d.ts | 32 | ||||
-rw-r--r-- | types/test/translator.d.ts (renamed from types/test/anki-note-builder.d.ts) | 25 |
2 files changed, 57 insertions, 0 deletions
diff --git a/types/test/dom-text-scanner.d.ts b/types/test/dom-text-scanner.d.ts new file mode 100644 index 00000000..362a7eb5 --- /dev/null +++ b/types/test/dom-text-scanner.d.ts @@ -0,0 +1,32 @@ +/* + * 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/>. + */ + +export type TestData = { + node: string; + offset: number; + length: number; + forcePreserveWhitespace?: boolean; + generateLayoutContent?: boolean; + reversible?: boolean; + expected: { + node: string; + offset: number; + content: string; + remainder?: number; + }; +}; + diff --git a/types/test/anki-note-builder.d.ts b/types/test/translator.d.ts index 0ccb25e9..3e4c8b9d 100644 --- a/types/test/anki-note-builder.d.ts +++ b/types/test/translator.d.ts @@ -17,6 +17,9 @@ import type {OptionsPresetObject} from 'dev/vm'; import type {FindTermsMode} from 'translator'; +import type {DictionaryEntry} from 'dictionary'; +import type {NoteData} from 'anki-templates'; +import type {NoteFields} from 'anki'; export type TranslatorTestInputs = { optionsPresets: OptionsPresetObject; @@ -39,3 +42,25 @@ export type TestInputFindTerm = { text: string; options: string; }; + +export type TranslatorTestResults = TranslatorTestResult[]; + +export type TranslatorTestResult = { + name: string; + originalTextLength?: number; + dictionaryEntries: DictionaryEntry[]; +}; + +export type TranslatorTestNoteDataResults = TranslatorTestNoteDataResult[]; + +export type TranslatorTestNoteDataResult = { + name: string; + noteDataList: NoteData[]; +}; + +export type AnkiNoteBuilderTestResults = AnkiNoteBuilderTestResult[]; + +export type AnkiNoteBuilderTestResult = { + name: string; + results: NoteFields[] | null; +}; |