@@ -17,6 +17,7 @@ Describe 'Render-SourcefileRow' {
1717<!--counter.methods-->
1818<!--counter.classes-->
1919<!--counter.complexity-->
20+ something
2021'@
2122 $template = $template.Replace (" `r`n " , " `n " )
2223 $expected = @'
@@ -30,6 +31,7 @@ sample.ps1
30310 - 5 - 5 - 100.00%
31320 - 3 - 3 - 100.00%
3233
34+ something
3335'@
3436 $expected = $expected.Replace (" `r`n " , " `n " )
3537 $object = [PSCustomObject ]@ {
@@ -84,4 +86,139 @@ sample.ps1
8486 $result = Render- SourcefileRow - template $template - object $object - directoryDepth $directoryDepth
8587 $result | Should - Be $expected
8688 }
89+ }
90+
91+ Describe ' Render-SourcefilesCard' {
92+ BeforeAll {
93+ . (Resolve-Path " $PSScriptRoot \..\..\..\src\templates\elements\sourcefiles.ps1" ).Path
94+ . (Resolve-Path " $PSScriptRoot \..\..\..\src\utilities\string.ps1" ).Path
95+ . (Resolve-Path " $PSScriptRoot \..\..\..\src\assets.ps1" ).Path
96+ }
97+
98+ It ' Should render card with two rows' {
99+ $cardTemplate = @'
100+ <!--page.theme-->
101+ <!--statistics rows-->
102+ <!--statistics card title-->
103+ '@
104+ $Global :jacocoxml2htmlConfig = [PSCustomObject ]@ {' theme' = ' dark' ;}
105+ $cardTemplate = $cardTemplate.Replace (" `r`n " , " `n " )
106+ $rowTemplate = @'
107+ sample row template
108+ '@
109+ $rowTemplate = $rowTemplate.Replace (" `r`n " , " `n " )
110+ $objects = [PSCustomObject []]@ (
111+ [PSCustomObject ]@ {
112+ " @name" = " directory\sample.ps1" ;
113+ " class" = [PSCustomObject []]@ (
114+ [PSCustomObject ]@ {
115+ " something" = " lorem ipsum" ;
116+ },
117+ [PSCustomObject ]@ {
118+ " something_else" = " lorem ipsum dolor" ;
119+ }
120+ );
121+ " sourcefile" = [PSCustomObject []]@ (
122+ [PSCustomObject ]@ {
123+ " something" = " lorem ipsum" ;
124+ },
125+ [PSCustomObject ]@ {
126+ " something_else" = " lorem ipsum dolor" ;
127+ },
128+ [PSCustomObject ]@ {
129+ " something" = " lorem ipsum" ;
130+ },
131+ [PSCustomObject ]@ {
132+ " something_else" = " lorem ipsum dolor" ;
133+ }
134+ );
135+ " counter" = [PSCustomObject []]@ (
136+ [PSCustomObject ]@ {
137+ " @type" = " INSTRUCTION" ;
138+ " @missed" = " 1" ;
139+ " @covered" = " 66" ;
140+ },
141+ [PSCustomObject ]@ {
142+ " @type" = " LINE" ;
143+ " @missed" = " 1" ;
144+ " @covered" = " 53" ;
145+ },
146+ [PSCustomObject ]@ {
147+ " @type" = " METHOD" ;
148+ " @missed" = " 0" ;
149+ " @covered" = " 5" ;
150+ },
151+ [PSCustomObject ]@ {
152+ " @type" = " CLASS" ;
153+ " @missed" = " 0" ;
154+ " @covered" = " 3" ;
155+ }
156+ );
157+ },
158+ [PSCustomObject ]@ {
159+ " @name" = " directory\another_sample.ps1" ;
160+ " class" = [PSCustomObject []]@ (
161+ [PSCustomObject ]@ {
162+ " something" = " lorem ipsum" ;
163+ },
164+ [PSCustomObject ]@ {
165+ " something_else" = " lorem ipsum dolor" ;
166+ }
167+ );
168+ " sourcefile" = [PSCustomObject []]@ (
169+ [PSCustomObject ]@ {
170+ " something" = " lorem ipsum" ;
171+ },
172+ [PSCustomObject ]@ {
173+ " something_else" = " lorem ipsum dolor" ;
174+ },
175+ [PSCustomObject ]@ {
176+ " something" = " lorem ipsum" ;
177+ },
178+ [PSCustomObject ]@ {
179+ " something_else" = " lorem ipsum dolor" ;
180+ }
181+ );
182+ " counter" = [PSCustomObject []]@ (
183+ [PSCustomObject ]@ {
184+ " @type" = " INSTRUCTION" ;
185+ " @missed" = " 15" ;
186+ " @covered" = " 66" ;
187+ },
188+ [PSCustomObject ]@ {
189+ " @type" = " LINE" ;
190+ " @missed" = " 12" ;
191+ " @covered" = " 53" ;
192+ },
193+ [PSCustomObject ]@ {
194+ " @type" = " METHOD" ;
195+ " @missed" = " 3" ;
196+ " @covered" = " 5" ;
197+ },
198+ [PSCustomObject ]@ {
199+ " @type" = " CLASS" ;
200+ " @missed" = " 0" ;
201+ " @covered" = " 3" ;
202+ }
203+ );
204+ }
205+ )
206+ $cardTitle = ' lorem ipsum'
207+ $directoryDepth = 2
208+ $expected = @'
209+ dark
210+ sample row template
211+ sample row template
212+ lorem ipsum
213+ '@
214+ $expected = $expected.Replace (" `r`n " , " `n " )
215+
216+ $result = Render- SourcefilesCard `
217+ - cardTemplate $cardTemplate `
218+ - rowTemplate $rowTemplate `
219+ - objects $objects `
220+ - cardTitle $cardTitle `
221+ - directoryDepth $directoryDepth
222+ $result | Should - Be $expected
223+ }
87224}
0 commit comments