From 0c8aa53a9000340ca5e08a3f5c7713c2d9c85a52 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 30 Jun 2020 09:39:48 +0500 Subject: [PATCH] Add new test for Format-Custom to avoid data loss (#11393) --- .../Format-Custom.Tests.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Custom.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Custom.Tests.ps1 index 4402d8bed7..92f4c3ff21 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Custom.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Custom.Tests.ps1 @@ -297,7 +297,16 @@ class MyLeaf2 $expectedResult = $expectedResult -replace "[{} `n\r]","" $result | Should -Be $expectedResult } -} + + It "Format-Custom should not lost data" { + # See https://github.com/PowerShell/PowerShell/pull/11342 for more information + $data = (Get-Help Out-Null).Examples + $formattedData = $data | Format-Custom | Out-String + $formattedData | Should -BeLike "*$($data.Example.title)*" + $formattedData | Should -BeLike "*$($data.Example.code)*" + $formattedData | Should -BeLike "*$($data.Example.remarks.Text)*" + } + } Describe "Format-Custom with expression based EntrySelectedBy in a CustomControl" -Tags "CI" { BeforeAll {