-
-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,48 @@ public void Should_Not_Throw_When_Selecting_An_Item_With_Escaped_Markup() | |
// Then | ||
console.Output.ShouldContain(@"[red]This text will never be red[/]"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Select_The_First_Leaf_Item() | ||
{ | ||
// Given | ||
var console = new TestConsole(); | ||
console.Profile.Capabilities.Interactive = true; | ||
console.Input.PushKey(ConsoleKey.Enter); | ||
|
||
// When | ||
var prompt = new SelectionPrompt<string>() | ||
.Title("Select one") | ||
.Mode(SelectionMode.Leaf) | ||
.AddChoiceGroup("Group one", "A", "B") | ||
.AddChoiceGroup("Group two", "C", "D"); | ||
var selection = prompt.Show(console); | ||
|
||
// Then | ||
selection.ShouldBe("A"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Select_The_Last_Leaf_Item_When_Wrapping_Around() | ||
{ | ||
// Given | ||
var console = new TestConsole(); | ||
console.Profile.Capabilities.Interactive = true; | ||
console.Input.PushKey(ConsoleKey.UpArrow); | ||
console.Input.PushKey(ConsoleKey.Enter); | ||
|
||
// When | ||
var prompt = new SelectionPrompt<string>() | ||
.Title("Select one") | ||
.Mode(SelectionMode.Leaf) | ||
.WrapAround() | ||
.AddChoiceGroup("Group one", "A", "B") | ||
.AddChoiceGroup("Group two", "C", "D"); | ||
var selection = prompt.Show(console); | ||
|
||
// Then | ||
selection.ShouldBe("D"); | ||
} | ||
|
||
Check failure on line 65 in test/Spectre.Console.Tests/Unit/Prompts/SelectionPromptTests.cs GitHub Actions / Build (linux)
Check failure on line 65 in test/Spectre.Console.Tests/Unit/Prompts/SelectionPromptTests.cs GitHub Actions / Build (linux)
|
||
|
||
} | ||
Check failure on line 67 in test/Spectre.Console.Tests/Unit/Prompts/SelectionPromptTests.cs GitHub Actions / Build (linux)
Check failure on line 67 in test/Spectre.Console.Tests/Unit/Prompts/SelectionPromptTests.cs GitHub Actions / Build (linux)
|