Fix issue with merge of 19068 (#19586)

This commit is contained in:
Travis Plunk 2023-04-28 10:50:46 -07:00 committed by GitHub
parent 2cc2d9c579
commit 17da21af20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,118 +301,6 @@ Describe "TabCompletion" -Tags CI {
$actual | Should -BeExactly $expected
}
It 'ForEach-Object member completion results should include methods' {
$res = TabExpansion2 -inputScript '1..10 | ForEach-Object -MemberName '
$res.CompletionMatches.CompletionText | Should -Contain "GetType"
}
It 'Should not complete void instance members' {
$res = TabExpansion2 -inputScript '([void]("")).'
$res.CompletionMatches | Should -BeNullOrEmpty
}
It 'Should complete custom constructor from class using the AST' {
$res = TabExpansion2 -inputScript 'class ConstructorTestClass{ConstructorTestClass ([string] $s){}};[ConstructorTestClass]::'
$res.CompletionMatches | Should -HaveCount 3
$completionText = $res.CompletionMatches.CompletionText | Sort-Object
$completionText -join ' ' | Should -BeExactly 'Equals( new( ReferenceEquals('
}
It 'Should show multiple constructors in the tooltip' {
$res = TabExpansion2 -inputScript 'class ConstructorTestClass{ConstructorTestClass ([string] $s){}ConstructorTestClass ([int] $i){}ConstructorTestClass ([int] $i, [bool]$b){}};[ConstructorTestClass]::new'
$res.CompletionMatches | Should -HaveCount 1
$completionText = $res.CompletionMatches.ToolTip
$completionText.replace("`r`n", [System.Environment]::NewLine).trim()
$expected = @'
ConstructorTestClass(string s)
ConstructorTestClass(int i)
ConstructorTestClass(int i, bool b)
'@
$expected.replace("`r`n", [System.Environment]::NewLine).trim()
$completionText.replace("`r`n", [System.Environment]::NewLine).trim() | Should -BeExactly $expected
}
It 'Should complete parameter in param block' {
$res = TabExpansion2 -inputScript 'Param($Param1=(Get-ChildItem -))' -cursorColumn 30
$res.CompletionMatches[0].CompletionText | Should -BeExactly '-Path'
}
It 'Should complete member in param block' {
$res = TabExpansion2 -inputScript 'Param($Param1=($PSVersionTable.))' -cursorColumn 31
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'Count'
}
It 'Should complete attribute argument in param block' {
$res = TabExpansion2 -inputScript 'Param([Parameter()]$Param1)' -cursorColumn 17
$names = [Parameter].GetProperties() | Where-Object CanWrite | ForEach-Object Name
$diffs = Compare-Object -ReferenceObject $res.CompletionMatches.CompletionText -DifferenceObject $names
$diffs | Should -BeNullOrEmpty
}
It 'Should complete argument for second parameter' {
$res = TabExpansion2 -inputScript 'Get-ChildItem -Path $HOME -ErrorAction '
$res.CompletionMatches[0].CompletionText | Should -BeExactly Break
}
It 'Should complete argument with validateset attribute after comma' {
$TestString = 'function Test-ValidateSet{Param([ValidateSet("Cat","Dog")]$Param1,$Param2)};Test-ValidateSet -Param1 Dog, -Param2'
$res = TabExpansion2 -inputScript $TestString -cursorColumn ($TestString.LastIndexOf(',') + 1)
$res.CompletionMatches[0].CompletionText | Should -BeExactly Cat
}
it 'Should complete "Value" parameter value in "Where-Object" for Enum property with no input' {
$res = TabExpansion2 -inputScript 'Get-Command | where-Object CommandType -eq '
$res.CompletionMatches[0].CompletionText | Should -BeExactly Alias
}
it 'Should complete "Value" parameter value in "Where-Object" for Enum property with partial input' {
$res = TabExpansion2 -inputScript 'Get-Command | where-Object CommandType -ne Ali'
$res.CompletionMatches[0].CompletionText | Should -BeExactly Alias
}
it 'Should complete the right hand side of a comparison operator when left is an Enum with no input' {
$res = TabExpansion2 -inputScript 'Get-Command | Where-Object -FilterScript {$_.CommandType -like '
$res.CompletionMatches[0].CompletionText | Should -BeExactly "'Alias'"
}
it 'Should complete the right hand side of a comparison operator when left is an Enum with partial input' {
$TempVar = Get-Command
$res = TabExpansion2 -inputScript '$tempVar[0].CommandType -notlike "Ali"'
$res.CompletionMatches[0].CompletionText | Should -BeExactly "'Alias'"
}
it 'Should complete the right hand side of a comparison operator when left is an Enum when cursor is on a newline' {
$res = TabExpansion2 -inputScript "Get-Command | Where-Object -FilterScript {`$_.CommandType -like`n"
$res.CompletionMatches[0].CompletionText | Should -BeExactly "'Alias'"
}
it 'Should complete provider dynamic parameters with quoted path' {
$Script = if ($IsWindows)
{
'Get-ChildItem -Path "C:\" -Director'
}
else
{
'Get-ChildItem -Path "/" -Director'
}
$res = TabExpansion2 -inputScript $Script
$res.CompletionMatches[0].CompletionText | Should -BeExactly '-Directory'
}
it 'Should complete dynamic parameters while providing values to non-string parameters' {
$res = TabExpansion2 -inputScript 'Get-Content -Path $HOME -Verbose:$false -'
$res.CompletionMatches.CompletionText | Should -Contain '-Raw'
}
It 'Should enumerate types when completing member names for Select-Object' {
$TestString = '"Hello","World" | select-object '
$res = TabExpansion2 -inputScript $TestString
$res | Should -HaveCount 1
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'Length'
}
Context "Format cmdlet's View paramter completion" {
BeforeAll {
$viewDefinition = @'