File size: 1,608 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "Test-Push-Location" -Tags "CI" {
    New-Variable -Name startDirectory -Value $(Get-Location).Path -Scope Global -Force

    BeforeEach { Set-Location $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 -BeTrue

	{ 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

	Set-Location $startDirectory
	Push-Location ..
	$cmdletDirectory = $(Get-Location).Path

	$aliasDirectory | Should -BeExactly $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
    Set-Location $startDirectory
}