2016-03-04 23:48:30 +01:00
|
|
|
Describe "Test-Push-Location" {
|
2015-10-22 23:50:22 +02:00
|
|
|
New-Variable -Name startDirectory -Value $(Get-Location).Path -Scope Global -Force
|
|
|
|
|
|
|
|
BeforeEach { cd $startDirectory }
|
|
|
|
|
|
|
|
It "Should be called without error" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ Push-Location } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to push to the root directory" {
|
2016-03-04 23:52:27 +01:00
|
|
|
# this works cross-platform
|
|
|
|
{ Push-Location / } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to use relative path to parent" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ Push-Location .. } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to use relative path to grandparent" {
|
2016-03-04 23:52:27 +01:00
|
|
|
Test-Path ../.. | Should Be $true
|
2015-10-23 00:11:07 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
{ Push-Location ../.. } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to push twice" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ Push-Location .. } | Should Not Throw
|
|
|
|
{ Push-Location .. } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to take a piped variable" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ ".." | Push-Location } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to call the pushd alias" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ pushd } | Should Not Throw
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to push to the same location between the alias and the cmdlet" {
|
2016-03-04 23:52:27 +01:00
|
|
|
pushd ..
|
|
|
|
$aliasDirectory = $(Get-Location).Path
|
2015-10-22 23:50:22 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
cd $startDirectory
|
|
|
|
Push-Location ..
|
|
|
|
$cmdletDirectory = $(Get-Location).Path
|
2015-10-22 23:50:22 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$aliasDirectory | Should Be $cmdletDirectory
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should produce a pathinfo object when the passthru parameter is used" {
|
2016-03-04 23:52:27 +01:00
|
|
|
Push-Location .. -PassThru | ForEach-Object { $_.GetType().Name | Should Be PathInfo }
|
2015-10-22 23:50:22 +02:00
|
|
|
}
|
2015-10-23 00:54:38 +02:00
|
|
|
|
|
|
|
# final cleanup
|
|
|
|
cd $startDirectory
|
2015-10-23 00:11:07 +02:00
|
|
|
}
|