-
Notifications
You must be signed in to change notification settings - Fork 393
/
Copy pathUseConsistentWhitespace.tests.ps1
608 lines (523 loc) · 23.6 KB
/
UseConsistentWhitespace.tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
BeforeAll {
$testRootDirectory = Split-Path -Parent $PSScriptRoot
Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
$ruleName = "PSUseConsistentWhitespace"
$ruleConfiguration = @{
Enable = $true
CheckInnerBrace = $false
CheckOpenBrace = $false
CheckOpenParen = $false
CheckOperator = $false
CheckPipe = $false
CheckSeparator = $false
CheckParameter = $false
}
$settings = @{
IncludeRules = @($ruleName)
Rules = @{
PSUseConsistentWhitespace = $ruleConfiguration
}
}
}
Describe "UseWhitespace" {
Context "When an open brace follows a keyword" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenBrace = $true
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $false
}
It "Should find a violation if an open brace does not follow whitespace" {
$def = 'if ($true){}'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should not find violation if an open brace follows a whitespace" {
$def = 'if($true) {}'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should not find violation if an open brace follows a foreach member invocation" {
$def = '(1..5).foreach{$_}'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should not find violation if an open brace follows a where member invocation" {
$def = '(1..5).where{$_}'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should not find violation if an open brace is on the next line" {
$def = @'
if ($true)
{
foo
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It 'Should not find a violation if an open paren is before an opening brace' {
Invoke-ScriptAnalyzer -ScriptDefinition '$ast.Find({ $oneAst -is [TypeExpressionAst] })' -Settings $settings |
Should -BeNullOrEmpty
}
}
Context "When a parenthesis follows a keyword" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $true
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $false
}
It "Should find violation in an if statement" {
$def = 'if($true) {}'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should not find a violation in a function definition" {
$def = @'
function foo($param1) {
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation in a param block" {
$def = @'
function foo() {
param( )
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation in a nested open paren" {
$def = @'
function foo($param) {
((Get-Process))
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation on a method call" {
$def = '$x.foo("bar")'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
}
Context "When there is whitespace around assignment and binary operators" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOperator = $true
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $false
$ruleConfiguration.IgnoreAssignmentOperatorInsideHashTable = $false
}
It "Should find a violation if no whitespace around an assignment operator" {
$def = '$x=1'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '=' ' = '
}
It "Should find a violation if no whitespace before an assignment operator" {
$def = '$x= 1'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should find a violation if no whitespace after an assignment operator" {
$def = '$x =1'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should find a violation if there is a whitespaces not of size 1 around an assignment operator" {
$def = '$x = 1'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' = ' ' = '
}
It "Should not find violation if there are whitespaces of size 1 around an assignment operator" {
$def = @'
$x = @"
"abc"
"@
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find violation if there are whitespaces of size 1 around an assignment operator for here string" {
$def = '$x = 1'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find violation if there are no whitespaces around DotDot operator" {
$def = '1..5'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find violation if a binary operator is followed by new line" {
$def = @'
$x = $true -and
$false
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It 'Should not find violation if there are whitespaces of size 1 around a unary operator starting with a dash' {
Invoke-ScriptAnalyzer -ScriptDefinition '$x -join $y' -Settings $settings | Should -BeNullOrEmpty
}
It 'Should find a violation if no whitespace around a unary operator starting with a dash' {
$def = '$x=1'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '=' ' = '
}
It 'Should find a violation if no whitespace before a unary operator starting with a dash' {
$def = '$x-join $Y'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It 'Should find a violation if no whitespace after a unary operator starting with a dash' {
$def = '$x -join$y'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It 'Should find a violation if there is a whitespaces not of size 1 around a unary operator starting with a dash' {
$def = '$x -join $y'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' -join ' ' -join '
}
It 'Should find a violation if there is no whitespace after a unary operator with a dash but nothing that preceds it' {
$def = '-join$x'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '-join' '-join '
}
It "Should find violation if not asked to ignore assignment operator in hash table" {
$def = @'
$ht = @{
variable = 3
other = 4
}
'@
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
}
Context "When asked to ignore assignment operator inside hash table" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOperator = $true
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $false
$ruleConfiguration.IgnoreAssignmentOperatorInsideHashTable = $true
}
It "Should not find violation if assignment operator is in multi-line hash table" {
$def = @'
$ht = @{
variable = 3
other = 4
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should find violation if assignment operator has extra space in single-line hash table" {
$def = @'
$h = @{
ht = @{a = 3; b = 4}
eb = 33
}
'@
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
It "Should find violation for extra space around non-assignment operator inside hash table" {
$def = @'
$ht = @{
variable = 3
other = 4 + 7
}
'@
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
}
Context "When a comma is not followed by a space" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $true
}
It "Should find a violation" {
$def = '$x = @(1,2)'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should not find a violation if a space follows a comma" {
$def = '$x = @(1, 2)'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
}
Context "When a semi-colon is not followed by a space" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $true
}
It "Should find a violation" {
$def = '$x = @{a=1;b=2}'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should not find a violation if a space follows a semi-colon" {
$def = '$x = @{a=1; b=2}'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a new-line follows a semi-colon" {
$def = @'
$x = @{
a=1;
b=2
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a end of input follows a semi-colon" {
$def = @'
$x = "abc";
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
}
Context "CheckPipe" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $true
$ruleConfiguration.CheckPipeForRedundantWhitespace = $false
$ruleConfiguration.CheckSeparator = $false
}
It "Should find a violation if there is no space after pipe" {
$def = 'Get-Item |foo'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should not find a violation if there is no space before pipe" {
$def = 'Get-Item| foo'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should not find a violation if there is one space too much before pipe" {
$def = 'Get-Item | foo'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should find a violation if there is one space too much after pipe" {
$def = 'Get-Item | foo'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should not find a violation if there is 1 space before and after a pipe" {
$def = 'Get-Item | foo'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a backtick is before the pipe" {
$def = @'
Get-Item `
| foo
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a new-line is after the pipe" {
$def = @'
Get-Item |
foo
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a backtick is after the pipe" {
$def = @'
Get-Item |`
foo
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
}
Context "CheckPipeForRedundantWhitespace" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $false
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckPipeForRedundantWhitespace = $true
$ruleConfiguration.CheckSeparator = $false
}
It "Should not find a violation if there is no space around pipe" {
$def = 'foo|bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should not find a violation if there is exactly one space around pipe" {
$def = 'foo | bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -BeNullOrEmpty
}
It "Should find a violation if there is one space too much before pipe" {
$def = 'foo | bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
It "Should find a violation if there is two spaces too much before pipe" {
$def = 'foo | bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
It "Should find a violation if there is one space too much after pipe" {
$def = 'foo | bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
It "Should find a violation if there is two spaces too much after pipe" {
$def = 'foo | bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
}
Context "CheckInnerBrace" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $true
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $false
}
It "Should find a violation if there is no space after opening brace" {
$def = 'if ($true) {Get-Item }'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should find a violation if there is no space after opening brace when there are 2 braces" {
$def = 'if ($true) {{ Get-Item } }'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should find a violation if there is no space before closing brace" {
$def = 'if ($true) { Get-Item}'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should find a violation if there is no space before closing brace when there are 2 braces" {
$def = 'if ($true) { { Get-Item }}'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 '' ' '
}
It "Should find a violation if there is more than 1 space after opening brace" {
$def = 'if($true) { Get-Item }'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
It "Should find a violation if there is more than 1 space before closing brace" {
$def = 'if($true) { Get-Item }'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
}
It "Should not find a violation if there is 1 space after the opening brace and 1 before the closing brace" {
$def = 'if($true) { Get-Item }'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if there is 1 space inside empty curly braces" {
$def = 'if($true) { }'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation for an empty hashtable" {
$def = '$hashtable = @{}'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a new-line is after the opening brace" {
$def = @'
if ($true) {
Get-Item }
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a backtick is after the opening brace" {
$def = @'
if ($true) {`
Get-Item }
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a new-line is before the closing brace" {
$def = @'
if ($true) { Get-Item
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should not find a violation if a backtick is before the closing brace" {
$def = @'
if ($true) { Get-Item `
}
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
}
Context "CheckParameter" {
BeforeAll {
$ruleConfiguration.CheckInnerBrace = $true
$ruleConfiguration.CheckOpenBrace = $false
$ruleConfiguration.CheckOpenParen = $false
$ruleConfiguration.CheckOperator = $false
$ruleConfiguration.CheckPipe = $false
$ruleConfiguration.CheckSeparator = $false
$ruleConfiguration.CheckParameter = $true
}
It "Should not find no violation when newlines are involved" {
$def = {foo -a $b `
-c d -d $e -f g `
-h i |
bar -h i `
-switch}
Invoke-ScriptAnalyzer -ScriptDefinition "$def" -Settings $settings | Should -Be $null
}
It "Should not find no violation if there is always 1 space between parameters except when using colon syntax" {
$def = 'foo -bar $baz @splattedVariable -bat -parameterName:$parameterValue'
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}
It "Should find 1 violation if there is 1 space too much before a parameter" {
$def = 'foo -bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
$violations.Count | Should -Be 1
$violations[0].Extent.Text | Should -Be 'foo'
$violations[0].SuggestedCorrections[0].Text | Should -Be ([string]::Empty)
}
It "Should find 1 violation if there is 1 space too much before a parameter value" {
$def = 'foo $bar'
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
$violations.Count | Should -Be 1
$violations[0].Extent.Text | Should -Be 'foo'
$violations[0].SuggestedCorrections[0].Text | Should -Be ([string]::Empty)
}
It "Should fix script to always have 1 space between parameters except when using colon syntax but not by default" {
$def = 'foo -bar $baz -ParameterName: $ParameterValue "$PSScriptRoot\module.psd1"'
Invoke-Formatter -ScriptDefinition $def |
Should -BeExactly $def -Because 'CheckParameter configuration is not turned on by default (yet) as the setting is new'
Invoke-Formatter -ScriptDefinition $def -Settings $settings |
Should -BeExactly 'foo -bar $baz -ParameterName: $ParameterValue "$PSScriptRoot\module.psd1"'
}
It "Should fix script when newlines are involved" {
$def = {foo -a $b `
-c d -d $e -f g `
-h i |
bar -h i `
-switch}
$expected = {foo -a $b `
-c d -d $e -f g `
-h i |
bar -h i `
-switch}
Invoke-Formatter -ScriptDefinition "$def" -Settings $settings |
Should -Be "$expected"
}
}
}