-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
6c18748
commit 767723d
Showing
3 changed files
with
57 additions
and
43 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
74 changes: 37 additions & 37 deletions
74
PwshSpectreConsole.Tests/prompts/Read-SpectreText.tests.ps1
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 |
---|---|---|
@@ -1,38 +1,38 @@ | ||
Remove-Module PwshSpectreConsole -Force -ErrorAction SilentlyContinue | ||
Import-Module "$PSScriptRoot\..\..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force | ||
Import-Module "$PSScriptRoot\..\TestHelpers.psm1" -Force | ||
|
||
Describe "Read-SpectreText" { | ||
InModuleScope "PwshSpectreConsole" { | ||
BeforeEach { | ||
$testAnswerColor = $null | ||
Mock Invoke-SpectrePromptAsync { | ||
$Prompt | Should -BeOfType [Spectre.Console.TextPrompt[string]] | ||
if ($Prompt.PromptStyle.Foreground) { | ||
$Prompt.PromptStyle.Foreground.ToMarkup() | Should -Be $testAnswerColor | ||
} | ||
} | ||
} | ||
|
||
It "prompts" { | ||
Read-SpectreText -Question (Get-RandomString) | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
|
||
It "prompts with a default answer" { | ||
Read-SpectreText -Question (Get-RandomString) -DefaultAnswer (Get-RandomString) | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
|
||
It "can allow an empty answer" { | ||
Read-SpectreText -AllowEmpty | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
|
||
It "can use a colored prompt" { | ||
$testAnswerColor = Get-RandomColor | ||
Read-SpectreText -Question (Get-RandomString) -AnswerColor $testAnswerColor | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
} | ||
Remove-Module PwshSpectreConsole -Force -ErrorAction SilentlyContinue | ||
Import-Module "$PSScriptRoot\..\..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force | ||
Import-Module "$PSScriptRoot\..\TestHelpers.psm1" -Force | ||
|
||
Describe "Read-SpectreText" { | ||
InModuleScope "PwshSpectreConsole" { | ||
BeforeEach { | ||
$testAnswerColor = $null | ||
Mock Invoke-SpectrePromptAsync { | ||
$Prompt | Should -BeOfType [Spectre.Console.TextPrompt[string]] | ||
if ($Prompt.PromptStyle.Foreground) { | ||
$Prompt.PromptStyle.Foreground.ToMarkup() | Should -Be $testAnswerColor | ||
} | ||
} | ||
} | ||
|
||
It "prompts" { | ||
Read-SpectreText -Question (Get-RandomString) | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
|
||
It "prompts with a default answer" { | ||
Read-SpectreText -Question (Get-RandomString) -DefaultAnswer (Get-RandomString) | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
|
||
It "can allow an empty answer" { | ||
Read-SpectreText -Message "What?" -AllowEmpty | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
|
||
It "can use a colored prompt" { | ||
$testAnswerColor = Get-RandomColor | ||
Read-SpectreText -Question (Get-RandomString) -AnswerColor $testAnswerColor | ||
Assert-MockCalled -CommandName "Invoke-SpectrePromptAsync" -Times 1 -Exactly | ||
} | ||
} | ||
} |
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