forked from dahlbyk/posh-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitPrompt.Tests.ps1
56 lines (49 loc) · 1.8 KB
/
GitPrompt.Tests.ps1
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
BeforeAll {
. $PSScriptRoot\Shared.ps1
}
Describe 'Write-VcsStatus Tests' {
BeforeAll {
Mock -ModuleName posh-git -CommandName git {
$OFS = " "
if ($args -contains 'rev-parse') {
$res = Invoke-Expression "&$gitbin $args"
return $res
}
Convert-NativeLineEnding -SplitLines @'
## master
A test/Foo.Tests.ps1
D test/Bar.Tests.ps1
M test/Baz.Tests.ps1
'@
}
}
Context 'AnsiConsole disabled' {
BeforeAll {
# Ensure these settings start out set to the default values
$global:GitPromptSettings = New-GitPromptSettings
$GitPromptSettings.AnsiConsole = $false
}
It 'Returns no output from Write-VcsStatus' {
# Verify that we are getting write-host output first
$OFS = ''
$res = Write-VcsStatus 6>&1
Should -Invoke -ModuleName posh-git -CommandName git -Exactly 1
"$res" | Should -BeExactly " [master +1 ~0 -0 ~]"
# Verify that there is no return value i.e. we get $null
$res = Write-VcsStatus 6>$null
$res | Should -BeExactly $null
}
}
Context 'AnsiConsole enabled' {
BeforeAll {
# Ensure these settings start out set to the default values
$global:GitPromptSettings = New-GitPromptSettings
$GitPromptSettings.AnsiConsole = $true
}
It 'Returns status output from Write-VcsStatus as string' {
$res = Write-VcsStatus
Should -Invoke -ModuleName posh-git -CommandName git -Exactly 1
$res | Should -BeExactly " ${csi}93m[${csi}39m${csi}96mmaster${csi}39m${csi}32m +1${csi}39m${csi}32m ~0${csi}39m${csi}32m -0${csi}39m${csi}96m ~${csi}39m${csi}93m]${csi}39m"
}
}
}