diff options
Diffstat (limited to 'tui/tui_test.go')
| -rw-r--r-- | tui/tui_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tui/tui_test.go b/tui/tui_test.go index 6ae8d73..de9caf0 100644 --- a/tui/tui_test.go +++ b/tui/tui_test.go @@ -1,6 +1,7 @@ package tui import ( + "strings" "testing" "adammathes.com/neko/models/feed" @@ -28,6 +29,8 @@ func TestUpdateWindowSizeNoPanic(t *testing.T) { func TestStateTransitions(t *testing.T) { m := NewModel() + m1, _ := m.Update(tea.WindowSizeMsg{Width: 80, Height: 24}) + m = m1.(Model) // Feed loaded feeds := []*feed.Feed{{Id: 1, Title: "Test Feed"}} @@ -55,4 +58,35 @@ func TestStateTransitions(t *testing.T) { if tm4.state != viewFeeds { t.Errorf("Expected back to viewFeeds, got %v", tm4.state) } + + // Test entering content view + tm5, _ := tm3.Update(tea.KeyMsg{Type: tea.KeyEnter}) + tm5m := tm5.(Model) + if tm5m.state != viewContent { + t.Errorf("Expected state viewContent, got %v", tm5m.state) + } + if !strings.Contains(tm5m.contentView.View(), "Test Item") { + t.Error("Expected content view to show item title") + } + + // Back from content to items + tm6, _ := tm5.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("q")}) + tm6m := tm6.(Model) + if tm6m.state != viewItems { + t.Errorf("Expected back to viewItems, got %v", tm6m.state) + } + + // Test View for all states + if v := m.View(); !strings.Contains(v, "NEKO TUI") { + t.Error("View should contain title") + } + if v := tm2.View(); !strings.Contains(v, "Feeds") { + t.Error("View should contain Feeds list") + } + if v := tm3.View(); !strings.Contains(v, "Items") && !strings.Contains(v, "Test Feed") { + t.Error("View should contain Items list or Feed title") + } + if v := tm5m.View(); !strings.Contains(v, "Test Item") { + t.Error("View should contain Item title in content view") + } } |
