Skip to content

Commit 93de69f

Browse files
committed
🧪 [test] Refactor output capturing in coverage tests
🧪 [test] Refactors the output capturing mechanism in the extended coverage test suite. - Modifies the mock for `Invoke-WithUtf8Encoding` to capture its first argument, which represents the complete rendered text block. - This change centralizes how rendered output is collected for test assertions. 🧹 [chore] Suppresses output capturing from the `Write-RenderedText` mock. - Prevents duplicate or partial text captures, as the output is now reliably collected by the `Invoke-WithUtf8Encoding` mock. Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>
1 parent 684fecb commit 93de69f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Tests/ColorScripts-Enhanced.CoverageExpansion.Tests.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,16 @@ Describe "ColorScripts-Enhanced extended coverage" {
613613
}
614614
Mock -CommandName Invoke-WithUtf8Encoding -ModuleName ColorScripts-Enhanced -MockWith {
615615
param($ScriptBlock, [object[]]$Arguments)
616+
617+
if ($null -ne $Arguments -and $Arguments.Count -gt 0) {
618+
$script:RenderedOutputs += $Arguments[0]
619+
}
620+
616621
& $ScriptBlock @Arguments
617622
}
618623
Mock -CommandName Write-RenderedText -ModuleName ColorScripts-Enhanced -MockWith {
619624
param($Text)
620-
$script:RenderedOutputs += $Text
625+
# Suppress direct console writes during tests; rendered text is captured via Invoke-WithUtf8Encoding mock.
621626
}
622627
}
623628

0 commit comments

Comments
 (0)