mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add tab completion for Export-Counter -FileFormat parameter (#3856)
* add tab completion for -FileFormat parameter * update expected error for invalid -FileFormat test case
This commit is contained in:
committed by
Travis Plunk
parent
a291834f39
commit
471f4e8a48
@@ -32,7 +32,8 @@ Describe "TabCompletion" -Tags CI {
|
||||
It 'Should complete format-table hashtable' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem | Format-Table @{ ' -cursorColumn 'Get-ChildItem | Format-Table @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 5
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Label', 'Width', 'Alignment', 'Expression', 'FormatString' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' ' | Should Be 'Alignment Expression FormatString Label Width'
|
||||
}
|
||||
|
||||
|
||||
@@ -45,37 +46,43 @@ Describe "TabCompletion" -Tags CI {
|
||||
param($cmd)
|
||||
$res = TabExpansion2 -inputScript "Get-ChildItem | $cmd -GroupBy @{ " -cursorColumn "Get-ChildItem | $cmd -GroupBy @{ ".Length
|
||||
$res.CompletionMatches.Count | Should Be 3
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Label', 'Expression', 'FormatString' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' ' | Should Be 'Expression FormatString Label'
|
||||
}
|
||||
|
||||
It 'Should complete format-list hashtable' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem | Format-List @{ ' -cursorColumn 'Get-ChildItem | Format-List @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 3
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Label', 'Expression', 'FormatString' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' ' | Should Be 'Expression FormatString Label'
|
||||
}
|
||||
|
||||
It 'Should complete format-wide hashtable' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem | Format-Wide @{ ' -cursorColumn 'Get-ChildItem | Format-Wide @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 2
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Expression', 'FormatString' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' ' | Should Be 'Expression FormatString'
|
||||
}
|
||||
|
||||
It 'Should complete format-custom hashtable' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem | Format-Custom @{ ' -cursorColumn 'Get-ChildItem | Format-Custom @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 2
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Expression', 'Depth' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' ' | Should Be 'Depth Expression'
|
||||
}
|
||||
|
||||
It 'Should complete Select-Object hashtable' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem | Select-Object @{ ' -cursorColumn 'Get-ChildItem | Select-Object @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 2
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Name', 'Expression' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' '| Should Be 'Expression Name'
|
||||
}
|
||||
|
||||
It 'Should complete Sort-Object hashtable' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem | Sort-Object @{ ' -cursorColumn 'Get-ChildItem | Sort-Object @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 3
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'Expression', 'Ascending', 'Descending' | Should Be $true}
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' '| Should Be 'Ascending Descending Expression'
|
||||
}
|
||||
|
||||
It 'Should complete New-Object hashtable' {
|
||||
@@ -86,7 +93,7 @@ Describe "TabCompletion" -Tags CI {
|
||||
}
|
||||
$res = TabExpansion2 -inputScript 'New-Object -TypeName X -Property @{ ' -cursorColumn 'New-Object -TypeName X -Property @{ '.Length
|
||||
$res.CompletionMatches.Count | Should Be 3
|
||||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'A', 'B', 'C' | Should Be $true}
|
||||
$res.CompletionMatches.CompletionText -join ' ' | Should Be 'A B C'
|
||||
}
|
||||
|
||||
It 'Should complete "Get-Process -Id " with Id and name in tooltip' {
|
||||
@@ -186,4 +193,11 @@ Describe "TabCompletion" -Tags CI {
|
||||
$res.CompletionMatches.CompletionText | Should Be "-option"
|
||||
}
|
||||
}
|
||||
|
||||
It 'Should complete "Export-Counter -FileFormat" with available output formats'-Skip:(!$IsWindows) {
|
||||
$res = TabExpansion2 -inputScript 'Export-Counter -FileFormat ' -cursorColumn 'Export-Counter -FileFormat '.Length
|
||||
$res.CompletionMatches.Count | Should Be 3
|
||||
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
|
||||
$completionText -join ' '| Should Be 'blg csv tsv'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,11 +177,6 @@ Describe "Feature tests for Export-Counter cmdlet" -Tags "Feature" {
|
||||
Parameters = "-MaxSize -2"
|
||||
ExpectedErrorId = "CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ExportCounterCommand"
|
||||
}
|
||||
@{
|
||||
Name = "Fails when given invalid file format"
|
||||
FileFormat = "dat"
|
||||
ExpectedErrorId = "CounterInvalidFormat,Microsoft.PowerShell.Commands.ExportCounterCommand"
|
||||
}
|
||||
)
|
||||
|
||||
foreach ($testCase in $testCases)
|
||||
|
||||
Reference in New Issue
Block a user