Skip to content

Commit

Permalink
Merge pull request #28 from ShaunLawrie/fix-windows-tests
Browse files Browse the repository at this point in the history
Fix tests for windows
  • Loading branch information
ShaunLawrie authored Feb 17, 2024
2 parents c1816c2 + 9778807 commit f644f5d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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($_)) {
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit f644f5d

Please sign in to comment.