package tests import ( "strings" "testing" "hosts-go/internal/core" "hosts-go/internal/tui" tea "github.com/charmbracelet/bubbletea" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestModelSelection(t *testing.T) { sample := `127.0.0.1 localhost 192.168.1.10 example.com` lines := strings.Split(sample, "\n") hf, _, err := core.ParseHostsContent(lines) require.NoError(t, err) m := tui.NewModel(hf) require.NotNil(t, m.SelectedEntry()) assert.Equal(t, "localhost", m.SelectedEntry().Hostname) // Move selection down nm, _ := m.Update(tea.KeyMsg{Type: tea.KeyDown}) m = nm.(tui.Model) assert.Equal(t, "example.com", m.SelectedEntry().Hostname) }