ps/Modules/Alkami.PowerShell.Choco/Public/Format-PackageTextWhitespace.Tests.ps1

72 lines
2.0 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
. $PSScriptRoot\..\..\Load-PesterModules.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.'
$functionPath = Join-Path -Path $here -ChildPath $sut
Write-Host "Overriding SUT: $functionPath"
Import-Module $functionPath -Force
$moduleForMock = ""
Describe "Format-PackageTextWhitespace" {
Context "When Called With Endlines" {
$myFakePackageString = @"
Alkami.Services.SRE.Blah 1.0.1
Alkami.Services.SRE.Legacy.FooBar 1.0.1
"@
$resultingPackageString = Format-PackageTextWhitespace $myFakePackageString
It "Removes Endlines"{
$resultingPackageString.Contains("\r\n") | Should -BeFalse
}
It "Leaves in Single Spaces"{
$resultingPackageString.Contains(" ") | Should -BeTrue
}
}
Context "When Called With Multiple Spaces"{
$myFakePackageString = "Alkami.Services.SRE.Blah 1.0.1"
$resultingPackageString = Format-PackageTextWhitespace $myFakePackageString
It "Removes Multiple Spaces"{
$resultingPackageString.Contains(" ") | Should -BeFalse
}
It "Leaves in Single Spaces"{
$resultingPackageString.Contains(" ") | Should -BeTrue
}
}
Context "When Called With Tabs" {
$myFakePackageString = "Alkami.Services.SRE.Blah`t1.0.1`tAlkami.Services.SRE.Legacy.FooBar`t1.0.1"
$resultingPackageString = Format-PackageTextWhitespace $myFakePackageString
It "Removes tabs"{
$resultingPackageString.Contains("`t") | Should -BeFalse
}
It "Leaves in Single Spaces" {
$resultingPackageString.Contains(" ") | Should -BeTrue
}
}
Context "When Called With Tabs And Spaces" {
$myFakePackageString = "Alkami.Services.SRE.Blah `t 1.0.1 `t Alkami.Services.SRE.Legacy.FooBar `t 1.0.1"
$resultingPackageString = Format-PackageTextWhitespace $myFakePackageString
It "Removes tabs"{
$resultingPackageString.Contains("`t") | Should -BeFalse
}
It "Leaves in Single Spaces" {
$resultingPackageString.Contains(" ") | Should -BeTrue
}
}
}