Skip to content

Commit 3f2e104

Browse files
author
Kapil Borle
committed
Add initial tests for AlignAssignmentStatement rule
1 parent 2e9940e commit 3f2e104

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed
Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1-
Import-Module PSScriptAnalyzer
2-
$ruleName = "AlignAssignmentStatement"
1+
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
2+
$testRootDirectory = Split-Path -Parent $directory
3+
4+
Import-Module PSScriptAnalyzer
5+
Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
6+
7+
$ruleConfiguration = @{
8+
Enable = $true
9+
AlignInHashtable = $true
10+
AlignInDSCConfiguration = $true
11+
}
12+
13+
$settings = @{
14+
IncludeRules = @("PSAlignAssignmentStatement")
15+
Rules = @{
16+
PSAlignAssignmentStatement = $ruleConfiguration
17+
}
18+
}
319

420
Describe "AlignAssignmentStatement" {
5-
Context "" {
6-
It "" {
21+
Context "Hashtable" {
22+
It "Should align assignment statements in a hashtable" {
23+
$def = @'
24+
$hashtable = @{
25+
property1 = "value"
26+
anotherProperty = "another value"
27+
}
28+
'@
29+
30+
# Expected output should be the following
31+
# $hashtable = @{
32+
# property1 = "value"
33+
# anotherProperty = "another value"
34+
# }
35+
36+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
37+
$violations.Count | Should Be 1
38+
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
739
}
840
}
941
}

0 commit comments

Comments
 (0)