diff --git a/PwshSpectreConsole.Tests/formatting/new_Format-SpectreTable.tests.ps1 b/PwshSpectreConsole.Tests/formatting/new_Format-SpectreTable.tests.ps1 index c3ac3693..38f90389 100644 --- a/PwshSpectreConsole.Tests/formatting/new_Format-SpectreTable.tests.ps1 +++ b/PwshSpectreConsole.Tests/formatting/new_Format-SpectreTable.tests.ps1 @@ -31,7 +31,7 @@ Describe "Format-SpectreTable" { $testData = Get-ChildItem "$PSScriptRoot" $verification = $testdata | Format-Table | Get-TableHeader $testResult = Format-SpectreTable -Data $testData -Border $testBorder -Color $testColor - $rows = $testResult -split "\r?\n" | Select-Object -Skip 1 -SkipLast 2 + $rows = $testResult -split "\r?\n" | Select-Object -Skip 1 | Select-Object -SkipLast 2 $header = $rows[0] $properties = $header -split '\|' | StripAnsi | ForEach-Object { if (-Not [String]::IsNullOrWhiteSpace($_)) { @@ -58,7 +58,7 @@ Describe "Format-SpectreTable" { It "Should be able to use calculated properties" { $Data = Get-Process -Id $pid $Format = $data | Format-SpectreTable ProcessName, @{Label="TotalRunningTime"; Expression={(Get-Date) - $_.StartTime}} -Border Markdown - $obj = $Format -split "\r?\n" | Select-Object -Skip 1 -SkipLast 2 + $obj = $Format -split "\r?\n" | Select-Object -Skip 1 | Select-Object -SkipLast 2 $deconstructed = $obj -split '\|' | StripAnsi | ForEach-Object { if (-Not [String]::IsNullOrEmpty($_)) { $_.Trim() diff --git a/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithProgress.tests.ps1 b/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithProgress.tests.ps1 index e17963de..646d97bc 100644 --- a/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithProgress.tests.ps1 +++ b/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithProgress.tests.ps1 @@ -2,9 +2,25 @@ Remove-Module PwshSpectreConsole -Force -ErrorAction SilentlyContinue Import-Module "$PSScriptRoot\..\..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force Import-Module "$PSScriptRoot\..\TestHelpers.psm1" -Force +$script:originalConsole = [Spectre.Console.AnsiConsole]::Console + Describe "Invoke-SpectreCommandWithProgress" -Tag "integration" { InModuleScope "PwshSpectreConsole" { + BeforeEach { + $writer = [System.IO.StringWriter]::new() + $output = [Spectre.Console.AnsiConsoleOutput]::new($writer) + $settings = [Spectre.Console.AnsiConsoleSettings]::new() + $settings.Out = $output + [Spectre.Console.AnsiConsole]::Console = [Spectre.Console.AnsiConsole]::Create($settings) + } + + AfterEach { + $settings = [Spectre.Console.AnsiConsoleSettings]::new() + $settings.Out = [Spectre.Console.AnsiConsoleOutput]::new([System.Console]::Out) + [Spectre.Console.AnsiConsole]::Console = [Spectre.Console.AnsiConsole]::Create($settings) + } + It "executes the scriptblock for the basic case" { Invoke-SpectreCommandWithProgress -ScriptBlock { param ( diff --git a/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithStatus.tests.ps1 b/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithStatus.tests.ps1 index 36890eeb..7e80d8b2 100644 --- a/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithStatus.tests.ps1 +++ b/PwshSpectreConsole.Tests/progress/Invoke-SpectreCommandWithStatus.tests.ps1 @@ -12,6 +12,18 @@ Describe "Invoke-SpectreCommandWithStatus" -Tag "integration" { Write-Debug $testTitle Write-Debug $testSpinner Write-Debug $testColor + + $writer = [System.IO.StringWriter]::new() + $output = [Spectre.Console.AnsiConsoleOutput]::new($writer) + $settings = [Spectre.Console.AnsiConsoleSettings]::new() + $settings.Out = $output + [Spectre.Console.AnsiConsole]::Console = [Spectre.Console.AnsiConsole]::Create($settings) + } + + AfterEach { + $settings = [Spectre.Console.AnsiConsoleSettings]::new() + $settings.Out = [Spectre.Console.AnsiConsoleOutput]::new([System.Console]::Out) + [Spectre.Console.AnsiConsole]::Console = [Spectre.Console.AnsiConsole]::Create($settings) } It "executes the scriptblock for the basic case" {