|
| 1 | +import { Position, Range } from 'vscode-languageserver'; |
| 2 | +interface AutoTestCase<T> { |
| 3 | + kind: string; |
| 4 | + title: string; |
| 5 | + tag?: string; |
| 6 | + expect: T; |
| 7 | + error?: { |
| 8 | + message: string; |
| 9 | + cause: string; |
| 10 | + }; |
| 11 | +} |
| 12 | +interface KeybindingExpect { |
| 13 | + /** |
| 14 | + * apply之后对应的函内容匹配 |
| 15 | + */ |
| 16 | + lines: string[] | RegExp[]; |
| 17 | + /** |
| 18 | + * apply之后对应的光标位置 |
| 19 | + */ |
| 20 | + cursor?: Position; |
| 21 | +} |
| 22 | +interface AutoTestKeybindCase extends AutoTestCase<KeybindingExpect> { |
| 23 | + kind: 'keybind'; |
| 24 | + range: Range; |
| 25 | + input: string; |
| 26 | + typeInNewLine?: boolean; |
| 27 | + keybind: string; |
| 28 | +} |
| 29 | +interface AutoTestCheckEditorCase extends AutoTestCase<KeybindingExpect> { |
| 30 | + kind: 'checkEditor'; |
| 31 | +} |
| 32 | +interface AutoEditExpect { |
| 33 | + /** |
| 34 | + * apply之后对应的函内容匹配 |
| 35 | + */ |
| 36 | + lines: string[] | RegExp[]; |
| 37 | + /** |
| 38 | + * apply之后对应的光标位置 |
| 39 | + */ |
| 40 | + cursor?: Position; |
| 41 | +} |
| 42 | +interface AutoTestAutoEditCase extends AutoTestCase<AutoEditExpect> { |
| 43 | + kind: 'autoedit'; |
| 44 | + range: Range; |
| 45 | + typeInNewLine?: boolean; |
| 46 | + input: string; |
| 47 | +} |
| 48 | +interface DefinitionExpect { |
| 49 | + continueAfterjumping: any; |
| 50 | + uri: string; |
| 51 | + line: string | RegExp; |
| 52 | + cursor?: number; |
| 53 | +} |
| 54 | +interface AutoTestDefinitionCase extends AutoTestCase<DefinitionExpect> { |
| 55 | + kind: 'definition'; |
| 56 | + continueAfterjumping?: boolean; |
| 57 | + range: Range; |
| 58 | +} |
| 59 | +interface HoverExpect { |
| 60 | + /** |
| 61 | + * hover的内容 |
| 62 | + */ |
| 63 | + content: string | RegExp; |
| 64 | + /** |
| 65 | + * 是否支持F1打开帮助文档 |
| 66 | + */ |
| 67 | + supportF1?: boolean; |
| 68 | +} |
| 69 | +interface AutoTestHoverCase extends AutoTestCase<HoverExpect> { |
| 70 | + kind: 'hover' | 'noerror' | 'error'; |
| 71 | + range: Range; |
| 72 | + docOffsetAt: number; |
| 73 | + type: 'string'; |
| 74 | +} |
| 75 | +interface OutlineExpect { |
| 76 | + filePath: string; |
| 77 | +} |
| 78 | +interface AutoTestOutlineCase extends AutoTestCase<OutlineExpect> { |
| 79 | + kind: 'outline'; |
| 80 | + needCreate?: boolean; |
| 81 | + project: string; |
| 82 | + lsDir: string; |
| 83 | + programData: string; |
| 84 | + programPlugin: string; |
| 85 | +} |
| 86 | +interface FormatExpect { |
| 87 | + filePath: string; |
| 88 | +} |
| 89 | +interface AutoTestFormatCase extends AutoTestCase<FormatExpect> { |
| 90 | + kind: 'format'; |
| 91 | + needCreate?: boolean; |
| 92 | + project: string; |
| 93 | + lsDir: string; |
| 94 | + programData: string; |
| 95 | + programPlugin: string; |
| 96 | +} |
| 97 | +interface FoldExpect { |
| 98 | + filePath: string; |
| 99 | +} |
| 100 | +interface AutoTestFoldCase extends AutoTestCase<FoldExpect> { |
| 101 | + kind: 'fold'; |
| 102 | + needCreate?: boolean; |
| 103 | + project: string; |
| 104 | + lsDir: string; |
| 105 | + programData: string; |
| 106 | + programPlugin: string; |
| 107 | +} |
| 108 | +interface OpenFileExpect { |
| 109 | + uri: string; |
| 110 | +} |
| 111 | +interface AutoTestOpenFileCase extends AutoTestCase<OpenFileExpect> { |
| 112 | +} |
| 113 | +interface ReferencesExpect { |
| 114 | + filePath: string; |
| 115 | +} |
| 116 | +interface AutoTestReferencesCase extends AutoTestCase<ReferencesExpect> { |
| 117 | + kind: 'references'; |
| 118 | + needCreate?: boolean; |
| 119 | + range: Range; |
| 120 | + docOffsetAt: number; |
| 121 | + project: string; |
| 122 | + lsDir: string; |
| 123 | + programData: string; |
| 124 | + programPlugin: string; |
| 125 | +} |
| 126 | +interface SameWordExpect { |
| 127 | + filePath: string; |
| 128 | +} |
| 129 | +interface AutoTestSameWordCase extends AutoTestCase<SameWordExpect> { |
| 130 | + kind: 'sameWord'; |
| 131 | + needCreate?: boolean; |
| 132 | + range: Range; |
| 133 | + docOffsetAt: number; |
| 134 | + project: string; |
| 135 | + lsDir: string; |
| 136 | + programData: string; |
| 137 | + programPlugin: string; |
| 138 | +} |
| 139 | +interface CommandExpect { |
| 140 | + lines: string[] | RegExp[]; |
| 141 | + cursor?: Position; |
| 142 | +} |
| 143 | +interface AutoTestCommandCase extends AutoTestCase<CommandExpect> { |
| 144 | + kind: 'command'; |
| 145 | + range: Range; |
| 146 | + typeInNewLine?: boolean; |
| 147 | + command: string; |
| 148 | +} |
| 149 | +interface ErrorExpect { |
| 150 | + content: string | RegExp; |
| 151 | +} |
| 152 | +interface CompletionExpect { |
| 153 | + /** |
| 154 | + * 代码助手列表项 |
| 155 | + */ |
| 156 | + items: string[]; |
| 157 | + /** |
| 158 | + * 代码助手列表项-不能包含项 |
| 159 | + */ |
| 160 | + excludeItems: string[]; |
| 161 | + /** |
| 162 | + * apply之后对应的行内容匹配 |
| 163 | + */ |
| 164 | + lines: string[] | RegExp[]; |
| 165 | + /** |
| 166 | + * apply之后对应的光标位置 |
| 167 | + */ |
| 168 | + cursor?: Position; |
| 169 | + /** |
| 170 | + * apply的item的详细信息 |
| 171 | + */ |
| 172 | + detail?: string | RegExp; |
| 173 | +} |
| 174 | +interface AutoTestCompletionCase extends AutoTestCase<CompletionExpect> { |
| 175 | + kind: 'completion' | 'init'; |
| 176 | + /** |
| 177 | + * 是否在新的一行写,如为true,则会在range位置回车后开始写 |
| 178 | + */ |
| 179 | + typeInNewLine?: boolean; |
| 180 | + /** |
| 181 | + * 要输入的位置 |
| 182 | + */ |
| 183 | + range: Range; |
| 184 | + /** |
| 185 | + * 要输入的文字 |
| 186 | + */ |
| 187 | + input: string; |
| 188 | + /** |
| 189 | + * 选择哪一项,默认是第一项。下标从`0`开始 |
| 190 | + */ |
| 191 | + applyIndex?: number; |
| 192 | +} |
| 193 | +interface AutoTestRetriggerCase extends AutoTestCase<CompletionExpect> { |
| 194 | + kind: 'retrigger'; |
| 195 | + typeInNewLine?: boolean; |
| 196 | + range: Range; |
| 197 | + input: string; |
| 198 | + applyIndex?: number; |
| 199 | +} |
| 200 | +interface AutoTestDbClickCase extends AutoTestCase<DbClickExpect> { |
| 201 | + kind: 'dbclick'; |
| 202 | + range: Range; |
| 203 | +} |
| 204 | +interface DbClickExpect { |
| 205 | + begin: string; |
| 206 | + end: string; |
| 207 | + match: string; |
| 208 | +} |
| 209 | +interface PerformanceExpect { |
| 210 | + expect: AutoTestDefinitionCase | AutoTestHoverCase | AutoTestCompletionCase; |
| 211 | +} |
| 212 | +interface AutoTestPerformanceCase extends AutoTestCase<PerformanceExpect> { |
| 213 | + kind: 'performance'; |
| 214 | + type: string; |
| 215 | + num: number; |
| 216 | + timer: number; |
| 217 | + range: Range; |
| 218 | +} |
| 219 | +export { AutoEditExpect, AutoTestAutoEditCase, AutoTestCase, AutoTestCheckEditorCase, AutoTestCompletionCase, AutoTestDbClickCase, AutoTestDefinitionCase, AutoTestFoldCase, AutoTestFormatCase, AutoTestHoverCase, AutoTestKeybindCase, AutoTestOpenFileCase, AutoTestOutlineCase, AutoTestPerformanceCase, AutoTestReferencesCase, AutoTestRetriggerCase, AutoTestSameWordCase, AutoTestCommandCase, CommandExpect, CompletionExpect, DbClickExpect, DefinitionExpect, ErrorExpect, FoldExpect, FormatExpect, HoverExpect, KeybindingExpect, OpenFileExpect, OutlineExpect, PerformanceExpect, ReferencesExpect, SameWordExpect, }; |
0 commit comments