Skip to content

Commit

Permalink
Remove 'Contain' operator, which is incompatible with latest Pester, …
Browse files Browse the repository at this point in the history
…from tests
  • Loading branch information
MathieuBuisson committed Oct 6, 2017
1 parent 0760ddb commit 0d1c10b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
82 changes: 41 additions & 41 deletions Tests/Integration/HtmlReport.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,105 +15,105 @@ Describe 'Invoke-PSCodeHealth HTML report' {
It 'Should have the expected <title> element' {
$ReportContent | Should Match '<title>PSCodeHealth Report - coveralls</title>'
}
It 'Should contain the expected CSS in the <style> element' {
It 'Should -FileContentMatch the expected CSS in the <style> element' {
$ReportContent | Should Match '(?smi)(<style>?\s+header\s>\s\.row\s\{).+</style>'
}
It 'Should contain the expected javascript in the <script> element' {
It 'Should -FileContentMatch the expected javascript in the <script> element' {
$ReportContent | Should Match '(?smi)(<script>?\s+Chart.pluginService.register.+\s+afterUpdate:\sfunction\s\(chart\)\s\{)'
}
It 'Should contain the correct heading' {
It 'Should -FileContentMatch the correct heading' {
$ReportContent | Should Match '\s+Code Health Report - <small>coveralls</small>'
}
It 'Should contain the correct value for the number of functions' {
It 'Should -FileContentMatch the correct value for the number of functions' {
$ReportContent | Should Match '(?smi)(Number of Functions</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>9</h2>)'
}
It 'Should contain the correct value for "Lines of Code - Total"' {
It 'Should -FileContentMatch the correct value for "Lines of Code - Total"' {
$ReportContent | Should Match '(?smi)(Lines of Code - Total</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>204</h2>)'
}
It 'Should contain the correct value for "ScriptAnalyzer Errors"' {
It 'Should -FileContentMatch the correct value for "ScriptAnalyzer Errors"' {
$ReportContent | Should Match '(?smi)(ScriptAnalyzer Errors</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>1</h2>)'
}
It 'Should contain the correct value for "ScriptAnalyzer Findings - Average"' {
It 'Should -FileContentMatch the correct value for "ScriptAnalyzer Findings - Average"' {
$ReportContent | Should Match '(?smi)(ScriptAnalyzer Findings - Average</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>0.44</h2>)'
}
It 'Should contain the correct value for "ScriptAnalyzer Info"' {
It 'Should -FileContentMatch the correct value for "ScriptAnalyzer Info"' {
$ReportContent | Should Match '(?smi)(ScriptAnalyzer Info</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>0</h2>)'
}
It 'Should contain the correct value for "Functions Without Help"' {
It 'Should -FileContentMatch the correct value for "Functions Without Help"' {
$ReportContent | Should Match '(?smi)(Functions Without Help</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>9</h2>)'
}
It 'Should contain the correct value for "Complexity - Highest"' {
It 'Should -FileContentMatch the correct value for "Complexity - Highest"' {
$ReportContent | Should Match '(?smi)(Complexity - Highest</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>5</h2>)'
}
It 'Should contain the correct value for "Nesting Depth - Highest"' {
It 'Should -FileContentMatch the correct value for "Nesting Depth - Highest"' {
$ReportContent | Should Match '(?smi)(Nesting Depth - Highest</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>3</h2>)'
}
It 'Should contain the correct value for "Lines of Code - Average"' {
It 'Should -FileContentMatch the correct value for "Lines of Code - Average"' {
$ReportContent | Should Match '(?smi)(Lines of Code - Average</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>22.67</h2>)'
}
It 'Should contain the correct value for "Complexity - Average"' {
It 'Should -FileContentMatch the correct value for "Complexity - Average"' {
$ReportContent | Should Match '(?smi)(Complexity - Average</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>2</h2>)'
}
It 'Should contain the correct value for "Nesting Depth - Average"' {
It 'Should -FileContentMatch the correct value for "Nesting Depth - Average"' {
$ReportContent | Should Match '(?smi)(Nesting Depth - Average</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>1.11</h2>)'
}
It 'Should contain the correct value for "Number of Tests"' {
It 'Should -FileContentMatch the correct value for "Number of Tests"' {
$ReportContent | Should Match '(?smi)(Number of Tests</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>13</h2>)'
}
It 'Should contain the correct value for "Number of Failed Tests"' {
It 'Should -FileContentMatch the correct value for "Number of Failed Tests"' {
$ReportContent | Should Match '(?smi)(Number of Failed Tests</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>2</h2>)'
}
It 'Should contain the correct value for "Number of Passed Tests"' {
It 'Should -FileContentMatch the correct value for "Number of Passed Tests"' {
$ReportContent | Should Match '(?smi)(Number of Passed Tests</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>11</h2>)'
}
It 'Should contain the correct value for "Number of Missed Commands"' {
It 'Should -FileContentMatch the correct value for "Number of Missed Commands"' {
$ReportContent | Should Match '(?smi)(Number of Missed Commands</h3>.\s+</div>.\s+<div class="panel-body">.\s+<h2>61</h2>)'
}
It 'Should contain the expected test "Should return 2 objects with the value 1" in the "Failed Tests Details" table' {
It 'Should -FileContentMatch the expected test "Should return 2 objects with the value 1" in the "Failed Tests Details" table' {
$ReportContent | Should Match '(?smi)(<td>97</td>.+\s+<td>Get-CoverageArray</td>.+\s+<td>Should return 2 objects with the value 1</td>.+\s+)'
}
It 'Should contain the expected test "Should return 0 objects with the value 0" in the "Failed Tests Details" table' {
It 'Should -FileContentMatch the expected test "Should return 0 objects with the value 0" in the "Failed Tests Details" table' {
$ReportContent | Should Match '(?smi)(<td>100</td>.+\s+<td>Get-CoverageArray</td>.+\s+<td>Should return 0 objects with the value 0</td>.+\s+)'
}
It 'Should contain 1 row per function in the "Per Function Information" table' {
It 'Should -FileContentMatch 1 row per function in the "Per Function Information" table' {
Foreach ( $FunctionName in $ExpectedFunctionNames ) {
$ReportContent | Should Match "\s+<td>$FunctionName</td>"
}
}
It 'Should contain the expected Best Practices row for the function "Add-CoverageInfo"' {
It 'Should -FileContentMatch the expected Best Practices row for the function "Add-CoverageInfo"' {
$ReportContent | Should Match '(?smi)(<td>Add-CoverageInfo</td>.+<td class="success">0</td>.+<td class=""></td>.+<td class="danger">False</td>.+\s+</tr>)'
}
It 'Should contain the expected Best Practices row for the function "Merge-CoverageResult"' {
It 'Should -FileContentMatch the expected Best Practices row for the function "Merge-CoverageResult"' {
$ReportContent | Should Match '(?smi)(<td>Merge-CoverageResult</td>.+<td class="success">0</td>.+<td class=""></td>.+<td class="danger">False</td>.+\s+</tr>)'
}
It 'Should contain the expected Best Practices row for the function "Format-Coverage"' {
It 'Should -FileContentMatch the expected Best Practices row for the function "Format-Coverage"' {
$ReportContent | Should Match '(?smi)(<td>Format-Coverage</td>.+<td class="success">0</td>.+<td class=""></td>.+<td class="danger">False</td>.+\s+</tr>)'
}
It 'Should contain the expected Best Practices row and button for the function "Get-CoverageArray"' {
It 'Should -FileContentMatch the expected Best Practices row and button for the function "Get-CoverageArray"' {
$ReportContent | Should Match '(?smi)(<td>Get-CoverageArray</td>.+<td class="success">2</td>.+<td class="danger">.+<button type="button" class="btn btn-danger btn-sm cell-expand-collapse"> Expand</button>)'
}
It 'Should contain the expected Best Practices row and button for the function "Get-GitInfo"' {
It 'Should -FileContentMatch the expected Best Practices row and button for the function "Get-GitInfo"' {
$ReportContent | Should Match '(?smi)(<td>Get-GitInfo</td>.+<td class="success">1</td>.+<td class="warning">.+<button type="button" class="btn btn-warning btn-sm cell-expand-collapse"> Expand</button>)'
}
It 'Should contain the expected Maintainability row for the function "Get-CoverageArray"' {
It 'Should -FileContentMatch the expected Maintainability row for the function "Get-CoverageArray"' {
$ReportContent | Should Match '(?smi)(<td>Get-CoverageArray</td>.+<td class="warning">31</td>.+<td class="success">5</td>.+<td class="success">3</td>.+\s+</tr>)'
}
It 'Should contain the expected Maintainability row for the function "Get-CommandsForFile"' {
It 'Should -FileContentMatch the expected Maintainability row for the function "Get-CommandsForFile"' {
$ReportContent | Should Match '(?smi)(<td>Get-CommandsForFile</td>.+<td class="success">16</td>.+<td class="success">1</td>.+<td class="success">1</td>.+\s+</tr>)'
}
It 'Should contain the expected Maintainability row for the function "Format-Coverage"' {
It 'Should -FileContentMatch the expected Maintainability row for the function "Format-Coverage"' {
$ReportContent | Should Match '(?smi)(<td>Format-Coverage</td>.+<td class="warning">39</td>.+<td class="success">3</td>.+<td class="success">1</td>.+\s+</tr>)'
}
It 'Should contain the expected Test Coverage row for the function "Add-CoverageInfo"' {
It 'Should -FileContentMatch the expected Test Coverage row for the function "Add-CoverageInfo"' {
$ReportContent | Should Match '(?smi)(<td>Add-CoverageInfo</td>.+<td class="danger">0</td>.+<td class="success">3</td>.+\s+</tr>)'
}
It 'Should contain the expected Test Coverage row for the function "Get-CoverageArray"' {
It 'Should -FileContentMatch the expected Test Coverage row for the function "Get-CoverageArray"' {
$ReportContent | Should Match '(?smi)(<td>Get-CoverageArray</td>.+<td class="success">94.74</td>.+<td class="success">1</td>.+\s+</tr>)'
}
It 'Should contain the expected Test Coverage row for the function "Publish-Coverage"' {
It 'Should -FileContentMatch the expected Test Coverage row for the function "Publish-Coverage"' {
$ReportContent | Should Match '(?smi)(<td>Publish-Coverage</td>.+<td class="danger">0</td>.+<td class="warning">10</td>.+\s+</tr>)'
}
It 'Should contain the expected Test Coverage row for the function "Get-CoveragePercentage"' {
It 'Should -FileContentMatch the expected Test Coverage row for the function "Get-CoveragePercentage"' {
$ReportContent | Should Match '(?smi)(<td>Get-CoveragePercentage</td>.+<td class="success">100</td>.+<td class="success">0</td>.+\s+</tr>)'
}
}
Expand Down Expand Up @@ -149,16 +149,16 @@ Describe 'HTML Report UI tests' {
$ActiveSidebar = $Driver.FindElementByCssSelector('.nav-sidebar > li.active')
$ActiveSidebar.Text | Should Be 'Style & Best Practices'
}
It 'The "bestPractices" section should contain 6 panels' {
It 'The "bestPractices" section Should -FileContentMatch 6 panels' {

$bestPracticesSection.FindElementsByClassName('panel-body').Count |
Should Be 6
}
It 'The "bestPractices" section should contain 1 "Per Function Information" table' {
It 'The "bestPractices" section Should -FileContentMatch 1 "Per Function Information" table' {

$bestPracticesPerFunctionTable.Count | Should Be 1
}
It 'The "Per Function Information" table should contain 3 buttons' {
It 'The "Per Function Information" table Should -FileContentMatch 3 buttons' {

$bestPracticesPerFunctionTable.FindElementsByTagName('button').Count |
Should Be 3
Expand Down Expand Up @@ -202,12 +202,12 @@ Describe 'HTML Report UI tests' {
$ActiveSidebar = $Driver.FindElementByCssSelector('.nav-sidebar > li.active')
$ActiveSidebar.Text | Should Be 'Maintainability'
}
It 'The "maintainability" section should contain 6 panels' {
It 'The "maintainability" section Should -FileContentMatch 6 panels' {

$maintainabilitySection.FindElementsByClassName('panel-body').Count |
Should Be 6
}
It 'The "maintainability" section should contain 1 "Per Function Information" table' {
It 'The "maintainability" section Should -FileContentMatch 1 "Per Function Information" table' {

$maintainabilityPerFunctionTable.Count | Should Be 1
}
Expand All @@ -234,16 +234,16 @@ Describe 'HTML Report UI tests' {
$ActiveSidebar = $Driver.FindElementByCssSelector('.nav-sidebar > li.active')
$ActiveSidebar.Text | Should Be 'Tests'
}
It 'The "Tests" section should contain 6 panels' {
It 'The "Tests" section Should -FileContentMatch 6 panels' {

$testsSection.FindElementsByClassName('panel-body').Count |
Should Be 6
}
It 'The "Tests" section should contain 1 "Failed Tests Details" table' {
It 'The "Tests" section Should -FileContentMatch 1 "Failed Tests Details" table' {
($testsTableTitles | Where-Object Text -eq 'Failed Tests Details').Count |
Should Be 1
}
It 'The "Tests" section should contain 1 "Per Function Information" table' {
It 'The "Tests" section Should -FileContentMatch 1 "Per Function Information" table' {
($testsTableTitles | Where-Object Text -eq 'Failed Tests Details').Count |
Should Be 1
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/Private/New-PSCodeHealthTableData.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Describe 'New-PSCodeHealthTableData' {

It 'Should have 1 best practices row for each function' {
Foreach ( $Function in $FunctionNames ) {
"$TestDrive\BestPracticesRows.txt" | Should Contain "<td>$Function</td>"
"$TestDrive\BestPracticesRows.txt" | Should -FileContentMatch "<td>$Function</td>"
}
}
It 'Should have 1 maintainability row for each function' {
Foreach ( $Function in $FunctionNames ) {
"$TestDrive\MaintainabilityRows.txt" | Should Contain "<td>$Function</td>"
"$TestDrive\MaintainabilityRows.txt" | Should -FileContentMatch "<td>$Function</td>"
}
}
It 'Should have 1 failed test row for each failed test' {
Expand All @@ -39,7 +39,7 @@ Describe 'New-PSCodeHealthTableData' {
}
It 'Should have 1 test coverage row for each function' {
Foreach ( $Function in $FunctionNames ) {
"$TestDrive\CoverageRows.txt" | Should Contain "<td>$Function</td>"
"$TestDrive\CoverageRows.txt" | Should -FileContentMatch "<td>$Function</td>"
}
}
}
Expand Down

0 comments on commit 0d1c10b

Please sign in to comment.