mirror of
https://github.com/shokinn/hosts-go.git
synced 2025-08-23 08:33:02 +00:00
Add edit mode toggle and entry activation
This commit is contained in:
parent
0c60248d75
commit
51966f766c
6 changed files with 69 additions and 17 deletions
|
@ -62,3 +62,26 @@ func TestPaneSwitching(t *testing.T) {
|
|||
m = nm.(tui.Model)
|
||||
assert.Equal(t, "localhost", m.SelectedEntry().Hostname)
|
||||
}
|
||||
|
||||
func TestEditModeToggleAndActivation(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)
|
||||
|
||||
// enter edit mode
|
||||
nm, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'e'}})
|
||||
m = nm.(tui.Model)
|
||||
assert.Equal(t, tui.EditMode, m.Mode())
|
||||
|
||||
// toggle active state of first entry
|
||||
nm, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}})
|
||||
m = nm.(tui.Model)
|
||||
assert.False(t, m.SelectedEntry().Active)
|
||||
|
||||
// status bar should reflect edit mode
|
||||
view := m.View()
|
||||
assert.Contains(t, view, "EDIT MODE")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue