(testObj: ITestWithRemapsObject)
| 332 | } |
| 333 | |
| 334 | async function testItWithRemaps(testObj: ITestWithRemapsObject): Promise<ModeHandler> { |
| 335 | const editor = vscode.window.activeTextEditor; |
| 336 | assert(editor, 'Expected an active editor'); |
| 337 | |
| 338 | await applyDocState(editor, DocState.parse(testObj.start)); |
| 339 | |
| 340 | // Generate a brand new ModeHandler for this editor |
| 341 | ModeHandlerMap.clear(); |
| 342 | const [modeHandler, _] = await ModeHandlerMap.getOrCreate(editor); |
| 343 | |
| 344 | const config = Globals.mockConfiguration; |
| 345 | |
| 346 | // Change remappings |
| 347 | if (testObj.remaps) { |
| 348 | if (!(testObj.remaps instanceof Array)) { |
| 349 | config.normalModeKeyBindings = testObj.remaps?.normalModeKeyBindings ?? []; |
| 350 | config.normalModeKeyBindingsNonRecursive = |
| 351 | testObj.remaps?.normalModeKeyBindingsNonRecursive ?? []; |
| 352 | config.insertModeKeyBindings = testObj.remaps?.insertModeKeyBindings ?? []; |
| 353 | config.insertModeKeyBindingsNonRecursive = |
| 354 | testObj.remaps?.insertModeKeyBindingsNonRecursive ?? []; |
| 355 | config.visualModeKeyBindings = testObj.remaps?.visualModeKeyBindings ?? []; |
| 356 | config.visualModeKeyBindingsNonRecursive = |
| 357 | testObj.remaps?.visualModeKeyBindingsNonRecursive ?? []; |
| 358 | config.operatorPendingModeKeyBindings = testObj.remaps?.operatorPendingModeKeyBindings ?? []; |
| 359 | config.operatorPendingModeKeyBindingsNonRecursive = |
| 360 | testObj.remaps?.operatorPendingModeKeyBindingsNonRecursive ?? []; |
| 361 | } else { |
| 362 | await parseVimRCMappings(testObj.remaps); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | const timeout = config.timeout; |
| 367 | const timeoutOffset = timeout / 2; |
| 368 | |
| 369 | await reloadConfiguration(config); |
| 370 | |
| 371 | for (const [index, step] of testObj.steps.entries()) { |
| 372 | const resolvedStep = (() => { |
| 373 | let start: DocState; |
| 374 | if (index === 0) { |
| 375 | start = DocState.parse(testObj.start); |
| 376 | } else { |
| 377 | const prevStepResult = testObj.steps[index - 1].stepResult; |
| 378 | start = DocState.parse(prevStepResult.endAfterTimeout ?? prevStepResult.end); |
| 379 | } |
| 380 | |
| 381 | const stepResult = testObj.steps[index].stepResult; |
| 382 | return { |
| 383 | start, |
| 384 | end: DocState.parse(stepResult.end), |
| 385 | endAfterTimeout: stepResult.endAfterTimeout |
| 386 | ? DocState.parse(stepResult.endAfterTimeout) |
| 387 | : undefined, |
| 388 | }; |
| 389 | })(); |
| 390 | |
| 391 | const stepTitleOrIndex = step.title ? `nr. ${index} - "${step.title}"` : index; |
nothing calls this directly
no test coverage detected