Skip to content

Commit d9dd860

Browse files
liamjpetersandyleejordan
authored andcommitted
Added test coverage for the scenarios of parameter values spanning multiple lines
1 parent 56c6ea1 commit d9dd860

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Tests/Rules/UseConsistentWhitespace.tests.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,42 @@ bar -h i `
585585
Should -Be "$expected"
586586
}
587587

588+
It "Should fix script when a parameter value is a script block spanning multiple lines" {
589+
$def = {foo {
590+
bar
591+
} -baz}
592+
593+
$expected = {foo {
594+
bar
595+
} -baz}
596+
Invoke-Formatter -ScriptDefinition "$def" -Settings $settings |
597+
Should -Be "$expected"
598+
}
599+
600+
It "Should fix script when a parameter value is a hashtable spanning multiple lines" {
601+
$def = {foo @{
602+
a = 1
603+
} -baz}
604+
605+
$expected = {foo @{
606+
a = 1
607+
} -baz}
608+
Invoke-Formatter -ScriptDefinition "$def" -Settings $settings |
609+
Should -Be "$expected"
610+
}
611+
612+
It "Should fix script when a parameter value is an array spanning multiple lines" {
613+
$def = {foo @(
614+
1
615+
) -baz}
616+
617+
$expected = {foo @(
618+
1
619+
) -baz}
620+
Invoke-Formatter -ScriptDefinition "$def" -Settings $settings |
621+
Should -Be "$expected"
622+
}
623+
588624
It "Should fix script when redirects are involved and whitespace is not consistent" {
589625
# Related to Issue #2000
590626
$def = 'foo 3>&1 1>$null 2>&1'

0 commit comments

Comments
 (0)