Skip to content

Commit a7c1f79

Browse files
committed
chore: ✏️ update CHANGELOG and module version to 0.3.2
* Added tests for different private commands. * Fixed for loop in `Get-PreviewPanel` to use the correct variable for scrolling.
1 parent b3097b7 commit a7c1f79

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [0.3.2] 2025-05-31
9+
10+
### Added
11+
12+
- Added tests for different private commands.
13+
14+
### Fixed
15+
16+
- Fixed for loop used to scroll which was using wrong variable.
17+
818
## [0.3.1] 2025-05-30
919

1020
### Added

PesterExplorer/PesterExplorer.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PesterExplorer.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.3.1'
15+
ModuleVersion = '0.3.2'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

PesterExplorer/Private/Get-PreviewPanel.ps1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function Get-PreviewPanel {
129129
Get-SpectreEscapedText |
130130
Format-SpectrePanel @formatSpectrePanelSplat
131131
} else {
132-
Write-Debug "Selected item is a Pester object: $($object.Name)"
132+
Write-Debug "Selected item '$($object.Name)'is a Pester object: $($object.GetType().Name)"
133133
$data = Format-PesterTreeHash -Object $object
134134
Write-Debug $($data|ConvertTo-Json -Depth 10)
135135
$formatSpectrePanelSplat = @{
@@ -151,7 +151,6 @@ function Get-PreviewPanel {
151151
$results += $object.StandardOutput |
152152
Get-SpectreEscapedText |
153153
Format-SpectrePanel @formatSpectrePanelSplat
154-
155154
}
156155

157156
# Print errors if they exist.
@@ -200,21 +199,21 @@ function Get-PreviewPanel {
200199
# If the scroll position is not zero, add a "back" item
201200
$reducedList += "[grey]...[/]"
202201
}
203-
for ($i = $scrollPosition; $i -le $array.Count; $i++) {
202+
for ($i = $scrollPosition; $i -lt $results.Count; $i++) {
204203
$itemHeight = Get-SpectreRenderableSize $results[$i]
205204
$totalHeight += $itemHeight.Height
206205
if ($totalHeight -gt $PreviewHeight) {
207206
if($i -eq $scrollPosition) {
208207
# If the first item already exceeds the height, stop here
209-
Write-Debug "First item exceeds preview height. Stopping."
208+
Write-Debug "First item exceeds preview height. Stopping. Total Height: $totalHeight, Preview Height: $PreviewHeight"
210209
$reducedList += ":police_car_light:The next item is too large to display! Please resize your terminal.:police_car_light:" |
211210
Format-SpectreAligned -HorizontalAlignment Center -VerticalAlignment Middle |
212211
Format-SpectrePanel -Header ":police_car_light: [red]Warning[/]" -Color 'red' -Border Double
213212
break
214213
}
215214
# If the total height exceeds the preview height, stop adding items
216215
Write-Debug "Total height exceeded preview height. Stopping at item $i."
217-
$reducedList += "[blue]...more.[/] [grey]Switch to Panel and scroll with keys.[/]"
216+
$reducedList += "[blue]...more. Switch to Panel and scroll with keys.[/]"
218217
break
219218
}
220219
$reducedList += $results[$i]

tests/Get-PreviewPanel.tests.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Describe 'Get-PreviewPanel' {
1414

1515
InModuleScope $env:BHProjectName {
1616
$script:ContainerWidth = 80
17-
$script:ContainerHeight = 100
17+
$script:ContainerHeight = 200
1818
$size = [Spectre.Console.Size]::new($containerWidth, $containerHeight)
1919
$script:renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
2020
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
@@ -77,15 +77,17 @@ Describe 'Get-PreviewPanel' {
7777
It 'should print warning when the screen is too small' {
7878
InModuleScope $env:BHProjectName {
7979
$Items = Get-ListFromObject -Object $script:run.Containers[0].Blocks[0].Order[0]
80-
$size = [Spectre.Console.Size]::new(80, 10)
80+
$height = 5
81+
$size = [Spectre.Console.Size]::new(80, $height)
8182
$renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
8283
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
8384
$size
8485
)
8586
$getPreviewPanelSplat = @{
8687
Items = $Items
8788
SelectedItem = 'Test1'
88-
PreviewHeight = 5
89+
ScrollPosition = 1
90+
PreviewHeight = $height
8991
PreviewWidth = $script:ContainerWidth
9092
}
9193
$panel = Get-PreviewPanel @getPreviewPanelSplat
@@ -100,14 +102,12 @@ Describe 'Get-PreviewPanel' {
100102
$getPreviewPanelSplat = @{
101103
Items = $Items
102104
SelectedItem = 'Test1'
103-
PreviewHeight = 100
104-
PreviewWidth = 100
105+
PreviewHeight = $script:ContainerHeight
106+
PreviewWidth = $script:ContainerWidth
105107
}
106-
Mock -CommandName 'Get-SpectreEscapedText' -Verifiable
107108
$panel = Get-PreviewPanel @getPreviewPanelSplat
108-
#global:Get-RenderedText -panel $panel -renderOptions $renderOptions -containerWidth 100 |
109-
# Should -BeLike 'Passed'
110-
Should -Invoke Get-SpectreEscapedText -Exactly 1 -Scope It
109+
global:Get-RenderedText -panel $panel -renderOptions $script:renderOptions -containerWidth $script:ContainerWidth |
110+
Should -BeLike '*$true | Should -Be $true*'
111111
}
112112
}
113113
}

0 commit comments

Comments
 (0)