Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Format.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ function Format-Nicely ($Value, [switch]$Pretty) {
return Format-ScriptBlock -Value $Value
}

# Check collection before Is-Value to format single item arrays
if (Is-Collection -Value $Value) {
return Format-Collection -Value $Value -Pretty:$Pretty
}

if (Is-Value -Value $Value) {
return $Value
}
Expand All @@ -141,10 +146,6 @@ function Format-Nicely ($Value, [switch]$Pretty) {
#return Format-Dictionary -Value $Value
}

if (Is-Collection -Value $Value) {
return Format-Collection -Value $Value -Pretty:$Pretty
}

# no advanced formatting of objects in the first version, till I balance it
return [string]$Value
# Format-Object -Value $Value -Property (Get-DisplayProperty $Value) -Pretty:$Pretty
Expand Down
3 changes: 2 additions & 1 deletion tst/Format.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ Describe "Format-Nicely" {
@{ Value = 1; Expected = '1' },
@{ Value = (1, 2, 3); Expected = '@(1, 2, 3)' },
@{ Value = 1.1; Expected = '1.1' },
@{ Value = [int]; Expected = '[int]' }
@{ Value = [int]; Expected = '[int]' },
@{ Value = @('a'); Expected = "@('a')" }
# @{ Value = [PSCustomObject] @{ Name = "Jakub" }; Expected = 'PSObject{Name=Jakub}' },
#@{ Value = (Get-Process Idle); Expected = 'Diagnostics.Process{Id=0; Name=Idle}'},
#@{ Value = (New-Object -Type Assertions.TestType.Person -Property @{Name = 'Jakub'; Age = 28}); Expected = "Assertions.TestType.Person{Age=28; Name=Jakub}"}
Expand Down
2 changes: 1 addition & 1 deletion tst/functions/assertions/HaveCount.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ InPesterModuleScope {

It "returns the correct assertion message when collection is not empty" {
$err = { @(1) | Should -HaveCount 0 -Because 'reason' } | Verify-AssertionFailed
$err.Exception.Message | Verify-Equal 'Expected an empty collection, because reason, but got collection with size 1 1.'
$err.Exception.Message | Verify-Equal 'Expected an empty collection, because reason, but got collection with size 1 @(1).'
}

It "validates the expected size to be bigger than 0" {
Expand Down