Skip to content

Commit

Permalink
Fix tests for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Feb 17, 2024
1 parent c1816c2 commit 9778807
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

This comment has been minimized.

Copy link
@trackd

trackd Feb 17, 2024

Collaborator

just an fyi, the github runners are upgraded to 7.4 so it supports combining these parameters now.

This comment has been minimized.

Copy link
@ShaunLawrie

ShaunLawrie Feb 18, 2024

Author Owner

Yeah haha I was being lazy because my local version was out of date. I reverted this in the branch I'm working on to use the spectre.console.testing library. https://github.com/ShaunLawrie/PwshSpectreConsole/pull/29/files

$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 9778807

Please sign in to comment.