TestPopoverTabCyclesSelection: Tab moves the selection to the next row without touching the textarea, zsh-style cycling.
(t *testing.T)
| 276 | // TestPopoverTabCyclesSelection: Tab moves the selection to the next row |
| 277 | // without touching the textarea, zsh-style cycling. |
| 278 | func TestPopoverTabCyclesSelection(t *testing.T) { |
| 279 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 280 | mm := typeInto(m, "/") |
| 281 | if !mm.popoverOpen() || len(mm.suggest) < 2 { |
| 282 | t.Fatalf("precondition: popover open with ≥2 options, got %d", len(mm.suggest)) |
| 283 | } |
| 284 | start := mm.suggestIdx |
| 285 | mm2, _ := mm.Update(tea.KeyMsg{Type: tea.KeyTab}) |
| 286 | if mm2.(Model).suggestIdx != (start+1)%len(mm.suggest) { |
| 287 | t.Fatalf("Tab should advance selection, got idx=%d (was %d)", |
| 288 | mm2.(Model).suggestIdx, start) |
| 289 | } |
| 290 | if got := mm2.(Model).ta.Value(); got != "/" { |
| 291 | t.Fatalf("textarea must not change on Tab cycle: %q", got) |
| 292 | } |
| 293 | if !mm2.(Model).popoverOpen() { |
| 294 | t.Fatal("popover should stay open after Tab") |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | // TestPopoverTabOnEmptyOpensCommandList: Tab on an empty textarea is |
| 299 | // equivalent to typing "/": it opens the popover with the full command |
nothing calls this directly
no test coverage detected