mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
* Fix GetType() bad pattern and related issues in tests $var.GetType() can raise an exception in tests so we should check $var before make the call. A large part of the tests does not make this check. I start with searching ".GetType()" but discovered many related issues in tests (reduntant and unneeded tests, "throw" bad pattens, bugs, formattings (sorry!) and so on) - I had to fix them too. * Fix after code review * Second wave of migration GetType() -> BeOfType Removed 'GetType().Name' patterns.
56 lines
1.4 KiB
PowerShell
56 lines
1.4 KiB
PowerShell
Describe "Test-Push-Location" -Tags "CI" {
|
|
New-Variable -Name startDirectory -Value $(Get-Location).Path -Scope Global -Force
|
|
|
|
BeforeEach { cd $startDirectory }
|
|
|
|
It "Should be called without error" {
|
|
{ Push-Location } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to push to the root directory" {
|
|
# this works cross-platform
|
|
{ Push-Location / } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to use relative path to parent" {
|
|
{ Push-Location .. } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to use relative path to grandparent" {
|
|
Test-Path ../.. | Should Be $true
|
|
|
|
{ Push-Location ../.. } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to push twice" {
|
|
{ Push-Location .. } | Should Not Throw
|
|
{ Push-Location .. } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to take a piped variable" {
|
|
{ ".." | Push-Location } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to call the pushd alias" {
|
|
{ pushd } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to push to the same location between the alias and the cmdlet" {
|
|
pushd ..
|
|
$aliasDirectory = $(Get-Location).Path
|
|
|
|
cd $startDirectory
|
|
Push-Location ..
|
|
$cmdletDirectory = $(Get-Location).Path
|
|
|
|
$aliasDirectory | Should Be $cmdletDirectory
|
|
}
|
|
|
|
It "Should produce a pathinfo object when the passthru parameter is used" {
|
|
Push-Location .. -PassThru | ForEach-Object { $_ | Should BeOfType "System.Management.Automation.PathInfo" }
|
|
}
|
|
|
|
# final cleanup
|
|
cd $startDirectory
|
|
}
|