mask default value when prompt is a secret

This commit is contained in:
Thomas Freudenberg
2021-01-13 21:12:44 +01:00
committed by Patrik Svensson
parent a3e11b24e5
commit dee3c01629
3 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1 @@
Favorite fruit? (******): ******

View File

@ -200,5 +200,23 @@ namespace Spectre.Console.Tests.Unit
result.Item1.ShouldBe(2);
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("SecretDefaultValue")]
public Task Should_Chose_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_Is_Secret()
{
// Given
var console = new FakeConsole();
console.Input.PushKey(ConsoleKey.Enter);
// When
console.Prompt(
new TextPrompt<string>("Favorite fruit?")
.Secret()
.DefaultValue("Banana"));
// Then
return Verifier.Verify(console.Output);
}
}
}