Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/Push-Location.Tests.ps1
T

55 lines
1.4 KiB
PowerShell
Raw Normal View History

2016-07-25 14:01:41 -07:00
Describe "Test-Push-Location" -Tags "CI" {
2015-10-22 14:50:22 -07:00
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
2015-10-22 14:50:22 -07:00
}
It "Should be able to push to the root directory" {
# this works cross-platform
{ Push-Location / } | Should Not Throw
2015-10-22 14:50:22 -07:00
}
It "Should be able to use relative path to parent" {
{ Push-Location .. } | Should Not Throw
2015-10-22 14:50:22 -07:00
}
It "Should be able to use relative path to grandparent" {
Test-Path ../.. | Should Be $true
2015-10-22 15:11:07 -07:00
{ Push-Location ../.. } | Should Not Throw
2015-10-22 14:50:22 -07:00
}
It "Should be able to push twice" {
{ Push-Location .. } | Should Not Throw
{ Push-Location .. } | Should Not Throw
2015-10-22 14:50:22 -07:00
}
It "Should be able to take a piped variable" {
{ ".." | Push-Location } | Should Not Throw
2015-10-22 14:50:22 -07:00
}
It "Should be able to call the pushd alias" {
{ pushd } | Should Not Throw
2015-10-22 14:50:22 -07:00
}
It "Should be able to push to the same location between the alias and the cmdlet" {
pushd ..
$aliasDirectory = $(Get-Location).Path
2015-10-22 14:50:22 -07:00
cd $startDirectory
Push-Location ..
$cmdletDirectory = $(Get-Location).Path
2015-10-22 14:50:22 -07:00
$aliasDirectory | Should Be $cmdletDirectory
2015-10-22 14:50:22 -07:00
}
It "Should produce a pathinfo object when the passthru parameter is used" {
Push-Location .. -PassThru | ForEach-Object { $_.GetType().Name | Should Be PathInfo }
2015-10-22 14:50:22 -07:00
}
2015-10-22 15:54:38 -07:00
# final cleanup
cd $startDirectory
2015-10-22 15:11:07 -07:00
}