Support J and K for navigating list prompts (#1877)

This commit is contained in:
Tobias Tengler
2025-08-13 18:23:26 +02:00
committed by GitHub
parent 0889c2f97c
commit a8b2f1f1e0
3 changed files with 78 additions and 18 deletions

View File

@@ -77,4 +77,35 @@ public sealed class InteractiveCommandTests
result.ExitCode.ShouldBe(0);
result.Output.EndsWith("[Apple;Apricot;Spectre Console]");
}
[Fact]
public void InteractiveCommand_WithMockedUserInputs_VimMotions_ProducesExpectedOutput()
{
// Given
TestConsole console = new();
console.Interactive();
// Your mocked inputs must always end with "Enter" for each prompt!
// Multi selection prompt: Choose first option
console.Input.PushKey(ConsoleKey.Spacebar);
console.Input.PushKey(ConsoleKey.Enter);
// Selection prompt: Choose second option
console.Input.PushKey(ConsoleKey.J);
console.Input.PushKey(ConsoleKey.Enter);
// Ask text prompt: Enter name
console.Input.PushTextWithEnter("Spectre Console");
var app = new CommandAppTester(null, new CommandAppTesterSettings(), console);
app.SetDefaultCommand<InteractiveCommand>();
// When
var result = app.Run();
// Then
result.ExitCode.ShouldBe(0);
result.Output.EndsWith("[Apple;Apricot;Spectre Console]");
}
}