1+ Describe ' Render-SourcefileRow' {
2+ BeforeAll {
3+ . (Resolve-Path " $PSScriptRoot \..\..\..\src\templates\elements\sourcefiles.ps1" ).Path
4+ . (Resolve-Path " $PSScriptRoot \..\..\..\src\utilities\string.ps1" ).Path
5+ . (Resolve-Path " $PSScriptRoot \..\..\..\src\assets.ps1" ).Path
6+ }
7+
8+ It ' Should render sourcefile row with data. Directory depth 3' {
9+ $template = @'
10+ <!--page.location-->
11+ <!--item.name-->
12+ <!--classes.count-->
13+ <!--sourcefiles.count-->
14+ <!--counter.instructions-->
15+ <!--counter.branches-->
16+ <!--counter.lines-->
17+ <!--counter.methods-->
18+ <!--counter.classes-->
19+ <!--counter.complexity-->
20+ '@
21+ $template = $template.Replace (" `r`n " , " `n " )
22+ $expected = @'
23+ ../../../sources/directory\sample.ps1.html
24+ sample.ps1
25+ 2
26+ 4
27+ 1 - 66 - 67 - 98.51%
28+
29+ 1 - 53 - 54 - 98.15%
30+ 0 - 5 - 5 - 100.00%
31+ 0 - 3 - 3 - 100.00%
32+
33+ '@
34+ $expected = $expected.Replace (" `r`n " , " `n " )
35+ $object = [PSCustomObject ]@ {
36+ " @name" = " directory\sample.ps1" ;
37+ " class" = [PSCustomObject []]@ (
38+ [PSCustomObject ]@ {
39+ " something" = " lorem ipsum" ;
40+ },
41+ [PSCustomObject ]@ {
42+ " something_else" = " lorem ipsum dolor" ;
43+ }
44+ );
45+ " sourcefile" = [PSCustomObject []]@ (
46+ [PSCustomObject ]@ {
47+ " something" = " lorem ipsum" ;
48+ },
49+ [PSCustomObject ]@ {
50+ " something_else" = " lorem ipsum dolor" ;
51+ },
52+ [PSCustomObject ]@ {
53+ " something" = " lorem ipsum" ;
54+ },
55+ [PSCustomObject ]@ {
56+ " something_else" = " lorem ipsum dolor" ;
57+ }
58+ );
59+ " counter" = [PSCustomObject []]@ (
60+ [PSCustomObject ]@ {
61+ " @type" = " INSTRUCTION" ;
62+ " @missed" = " 1" ;
63+ " @covered" = " 66" ;
64+ },
65+ [PSCustomObject ]@ {
66+ " @type" = " LINE" ;
67+ " @missed" = " 1" ;
68+ " @covered" = " 53" ;
69+ },
70+ [PSCustomObject ]@ {
71+ " @type" = " METHOD" ;
72+ " @missed" = " 0" ;
73+ " @covered" = " 5" ;
74+ },
75+ [PSCustomObject ]@ {
76+ " @type" = " CLASS" ;
77+ " @missed" = " 0" ;
78+ " @covered" = " 3" ;
79+ }
80+ );
81+ }
82+ $directoryDepth = 3
83+
84+ $result = Render- SourcefileRow - template $template - object $object - directoryDepth $directoryDepth
85+ $result | Should - Be $expected
86+ }
87+ }
0 commit comments