feat: add navigation and window size handlers with corresponding tests

This commit is contained in:
Stevan Freeborn
2025-12-29 13:45:28 -06:00
parent 3bc730db87
commit 3d3877ca41
17 changed files with 1012 additions and 0 deletions
@@ -0,0 +1,51 @@
package handlers_test
import (
"testing"
"github.com/StevanFreeborn/term-tier/internal/handlers"
"github.com/StevanFreeborn/term-tier/internal/state"
tea "github.com/charmbracelet/bubbletea"
)
func TestNewTrackWindowSizeHandler(t *testing.T) {
h := handlers.NewTrackWindowSizeHandler()
if h == nil {
t.Error("Expected NewTrackWindowSizeHandler to return a handler, got nil")
}
}
func TestTrackWindowSizeHandler_Match(t *testing.T) {
h := handlers.NewTrackWindowSizeHandler()
s := state.New()
msg := tea.WindowSizeMsg{Width: 100, Height: 100}
if !h.Match(s, msg) {
t.Error("Expected Match to return true for WindowSizeMsg")
}
}
func TestTrackWindowSizeHandler_Handle(t *testing.T) {
h := handlers.NewTrackWindowSizeHandler()
s := state.New()
expectedWidth := 1024
expectedHeight := 768
msg := tea.WindowSizeMsg{Width: expectedWidth, Height: expectedHeight}
cmd := h.Handle(s, msg)
if s.WindowWidth() != expectedWidth {
t.Errorf("Expected WindowWidth to be %d, got %d", expectedWidth, s.WindowWidth())
}
if s.WindowHeight() != expectedHeight {
t.Errorf("Expected WindowHeight to be %d, got %d", expectedHeight, s.WindowHeight())
}
if cmd != nil {
t.Error("Expected Handle to return nil")
}
}