From d35e13afdb96705131cb4809aecf6e26a392bcc8 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 7 Aug 2015 14:39:17 -0700 Subject: [PATCH] Fix list of props test and merge cruft --- src/pester-tests/Test-Format-List.Tests.ps1 | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pester-tests/Test-Format-List.Tests.ps1 b/src/pester-tests/Test-Format-List.Tests.ps1 index af25885c2f..da0069abb8 100644 --- a/src/pester-tests/Test-Format-List.Tests.ps1 +++ b/src/pester-tests/Test-Format-List.Tests.ps1 @@ -7,13 +7,11 @@ Describe "Test-Format-List" { It "Should call format list without error" { { $input | Format-List } | Should Not Throw { $input | Format-List } | Should Not BeNullOrEmpty - } It "Should be able to call the alias" { { $input | fl } | Should Not Throw { $input | fl } | Should Not BeNullOrEmpty - } It "Should have the same output whether choosing alias or not" { @@ -21,7 +19,6 @@ Describe "Test-Format-List" { $actual = $input | fl | Out-String $actual | Should Be $expected - } It "Should produce the expected output" { @@ -36,26 +33,26 @@ Describe "Test-Format-List" { It "Should be able to call a property of the piped input" { # Tested on two input commands to verify functionality. - { Get-Process | Format-List -Property Name } | Should Not Throw { Get-Process | Format-List -Property Name } | Should Not BeNullOrEmpty { Get-Date | Format-List -Property DisplayName } | Should Not Throw { Get-Date | Format-List -Property DisplayName } | Should Not BeNullOrEmpty - } It "Should be able to display a list of props when separated by a comma" { { Get-Process | Format-List -Property Name,BasePriority } | Should Not Throw - $output = ( Get-Process | Format-List -Property Name,BasePriority | Out-String) + (Get-Process | Format-List -Property Name,BasePriority | Out-String) -Split "`n" | + Where-Object { $_.trim() -ne "" } | + ForEach-Object { $_ | Should Match "(Name)|(BasePriority)" } } It "Should show the requested prop in every element" { # Testing each element of format-list, using a for-each loop since the Format-List is so opaque (Get-Process | Format-List -Property CPU | Out-String) -Split "`n" | Where-Object { $_.trim() -ne "" } | - ForEach-Object {$_ | Should Match "CPU :" } + ForEach-Object { $_ | Should Match "CPU :" } } It "Should not show anything other than the requested props" { @@ -67,8 +64,6 @@ Describe "Test-Format-List" { } It "Should be able to take input without piping objects to it" { - $output = { Format-List -InputObject $input } - $output = { Format-List -InputObject $input } $output | Should Not Throw