Skip to content

Commit d683d46

Browse files
author
Kapil Borle
committed
Update tests for usewhitespace rule
1 parent d2581f6 commit d683d46

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Tests/Rules/UseWhitespace.tests.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $ruleConfiguration = @{
55
CheckOpenBrace = $false
66
CheckOpenParen = $false
77
CheckOperator = $false
8+
CheckSeparator = $false
89
}
910

1011
$settings = @{
@@ -21,6 +22,7 @@ Describe "UseWhitespace" {
2122
$ruleConfiguration.CheckOpenBrace = $true
2223
$ruleConfiguration.CheckOpenParen = $false
2324
$ruleConfiguration.CheckOperator = $false
25+
$ruleConfiguration.CheckSeparator = $false
2426
}
2527

2628
It "Should find a violation if an open brace does not follow whitespace" {
@@ -47,6 +49,7 @@ if($true) {}
4749
$ruleConfiguration.CheckOpenBrace = $false
4850
$ruleConfiguration.CheckOpenParen = $true
4951
$ruleConfiguration.CheckOperator = $false
52+
$ruleConfiguration.CheckSeparator = $false
5053
}
5154

5255
It "Should find violation in an if statement" {
@@ -101,6 +104,7 @@ $x.foo("bar")
101104
$ruleConfiguration.CheckOpenParen = $false
102105
$ruleConfiguration.CheckOpenBrace = $false
103106
$ruleConfiguration.CheckOperator = $true
107+
$ruleConfiguration.CheckSeparator = $false
104108
}
105109

106110
It "Should find a violation if no whitespace around an assignment operator" {
@@ -137,6 +141,16 @@ $x = 1
137141

138142
It "Should not find violation if there are whitespaces of size 1 around an assignment operator" {
139143
$def = @'
144+
$x = @"
145+
"abc"
146+
"@
147+
'@
148+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
149+
$violations.Count | Should Be 0
150+
}
151+
152+
It "Should not find violation if there are whitespaces of size 1 around an assignment operator for here string" {
153+
$def = @'
140154
$x = 1
141155
'@
142156
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings

0 commit comments

Comments
 (0)