mirror of
https://github.com/shokinn/hosts-go.git
synced 2025-08-23 08:33:02 +00:00
Implement TUI pane navigation
This commit is contained in:
parent
3561d15858
commit
a24041d664
6 changed files with 137 additions and 73 deletions
|
@ -45,3 +45,20 @@ func TestViewModeStatusBar(t *testing.T) {
|
|||
assert.Contains(t, view, "[✓] localhost")
|
||||
assert.Contains(t, view, "[ ] example.com")
|
||||
}
|
||||
|
||||
func TestPaneSwitching(t *testing.T) {
|
||||
sample := "127.0.0.1 localhost\n192.168.1.10 example.com"
|
||||
lines := strings.Split(sample, "\n")
|
||||
hf, _, err := core.ParseHostsContent(lines)
|
||||
require.NoError(t, err)
|
||||
|
||||
m := tui.NewModel(hf)
|
||||
// Switch focus to detail pane
|
||||
nm, _ := m.Update(tea.KeyMsg{Type: tea.KeyTab})
|
||||
m = nm.(tui.Model)
|
||||
|
||||
// Attempt to move down; selection should remain on first entry
|
||||
nm, _ = m.Update(tea.KeyMsg{Type: tea.KeyDown})
|
||||
m = nm.(tui.Model)
|
||||
assert.Equal(t, "localhost", m.SelectedEntry().Hostname)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue