Skip to content

Commit 368cfd3

Browse files
committed
Fix #2201: Add test for AlignAssignmentStatement to check SuggestedCorrection format
1 parent f9f380d commit 368cfd3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Tests/Rules/AlignAssignmentStatement.tests.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ Configuration C1 {
126126

127127
Context 'When Hashtable checking is enabled' {
128128

129+
It 'Should set correction file and description when analyzing a file' {
130+
$path = Join-Path -Path $TestDrive -ChildPath 'unaligned.ps1'
131+
Set-Content -LiteralPath $path -Value '@{"Key" = "Value"}'
132+
133+
$settings = New-AlignAssignmentSettings -CheckHashtable $true
134+
135+
$violations = Invoke-ScriptAnalyzer -Path $path -Settings $settings |
136+
Get-NonParseDiagnostics
137+
138+
$violations | Should -HaveCount 1
139+
$correction = $violations[0].SuggestedCorrections[0]
140+
$correction.File | Should -Be ([IO.Path]::GetFullPath($path))
141+
$correction.Description | Should -Be 'Assignment statements are not aligned'
142+
}
143+
129144
It 'Should not find violations in empty single-line hashtable' {
130145
$def = '@{}'
131146

0 commit comments

Comments
 (0)