Skip to content

Commit 4b2eb7a

Browse files
committed
test: cover WindowSizeMsg handler in model
Adds test for the tea.WindowSizeMsg branch in Update, covering the SetWidth/SetHeight calls that were missing from patch coverage.
1 parent d2d3de1 commit 4b2eb7a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

internal/shell/model_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,21 @@ func TestHostnames(t *testing.T) {
516516
}
517517
}
518518

519+
func TestWindowSizeMsgSetsViewportAndInput(t *testing.T) {
520+
m := initialModel(nil, nil, nil)
521+
updated, cmd := m.Update(tea.WindowSizeMsg{Width: 120, Height: 40})
522+
if cmd != nil {
523+
t.Fatalf("expected nil cmd, got %v", cmd)
524+
}
525+
um := updated.(model)
526+
if um.viewport.Width() != 120 {
527+
t.Fatalf("expected viewport width 120, got %d", um.viewport.Width())
528+
}
529+
if um.viewport.Height() != 39 {
530+
t.Fatalf("expected viewport height 39, got %d", um.viewport.Height())
531+
}
532+
}
533+
519534
func TestInitReturnsNilCmdWithoutEvents(t *testing.T) {
520535
m := initialModel(nil, nil, nil)
521536
if cmd := m.Init(); cmd != nil {

0 commit comments

Comments
 (0)