bbebf2f76a
- Pester source code moved to `test/Pester`, deleted `ext-src`. - Pester tests (.ps1 files) moved to `test/powershell` - xUnit tests (.cs files) moved to `test/csharp` - Third-party script test moved to `test/shebang`
55 lines
1.5 KiB
PowerShell
55 lines
1.5 KiB
PowerShell
Describe "Test-Push-Location" {
|
|
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 { $_.GetType().Name | Should Be PathInfo }
|
|
}
|
|
|
|
# final cleanup
|
|
cd $startDirectory
|
|
}
|