mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Do not append suffix to text prompt
Do not append suffix to text prompt unless there are choices or a default value specified. Closes #413
This commit is contained in:

committed by
Patrik Svensson

parent
865552c3f2
commit
2011cb2eff
@ -12,6 +12,20 @@ namespace Spectre.Console.Tests.Unit
|
||||
[ExpectationPath("Widgets/Prompt/Text")]
|
||||
public sealed class TextPromptTests
|
||||
{
|
||||
[Fact]
|
||||
public void Should_Return_Entered_Text()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
console.Input.PushTextWithEnter("Hello World");
|
||||
|
||||
// When
|
||||
var result = console.Prompt(new TextPrompt<string>("Enter text:"));
|
||||
|
||||
// Then
|
||||
result.ShouldBe("Hello World");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("ConversionError")]
|
||||
public Task Should_Return_Validation_Error_If_Value_Cannot_Be_Converted()
|
||||
@ -218,5 +232,22 @@ namespace Spectre.Console.Tests.Unit
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("NoSuffix")]
|
||||
[GitHubIssue(413)]
|
||||
public Task Should_Not_Append_Questionmark_Or_Colon_If_No_Choices_Are_Set()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
console.Input.PushTextWithEnter("Orange");
|
||||
|
||||
// When
|
||||
console.Prompt(
|
||||
new TextPrompt<string>("Enter command$"));
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user