gostations/internal/ui/ui_test.go

30 lines
635 B
Go
Raw Normal View History

package ui
import (
"testing"
tea "github.com/charmbracelet/bubbletea"
"github.com/gmgauthier/gostations/internal/radio"
)
func TestApp_BasicKeyHandling(t *testing.T) {
app := NewApp([]radio.Station{
{Name: "Test1", Url: "http://a", Codec: "MP3", Bitrate: "128"},
})
// Send q
model, cmd := app.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'q'}})
if !model.(*App).quitting {
t.Error("q did not set quitting")
}
_ = cmd
// Send window size
model, _ = app.Update(tea.WindowSizeMsg{Width: 80, Height: 24})
a := model.(*App)
if a.list.Width() == 0 {
t.Log("list size not updated (may be ok in test)")
}
}