TestPopoverTabOnEmptyOpensCommandList: Tab on an empty textarea is equivalent to typing "/": it opens the popover with the full command list. Subsequent Tabs cycle.
(t *testing.T)
| 299 | // equivalent to typing "/": it opens the popover with the full command |
| 300 | // list. Subsequent Tabs cycle. |
| 301 | func TestPopoverTabOnEmptyOpensCommandList(t *testing.T) { |
| 302 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 303 | if m.ta.Value() != "" || m.popoverOpen() { |
| 304 | t.Fatal("precondition: empty textarea, popover closed") |
| 305 | } |
| 306 | mm, _ := m.Update(tea.KeyMsg{Type: tea.KeyTab}) |
| 307 | om := mm.(Model) |
| 308 | if !om.popoverOpen() { |
| 309 | t.Fatal("Tab on empty should open the command popover") |
| 310 | } |
| 311 | if om.ta.Value() != "/" { |
| 312 | t.Fatalf("textarea should be seeded with '/' got %q", om.ta.Value()) |
| 313 | } |
| 314 | if len(om.suggest) != len(commands) { |
| 315 | t.Fatalf("popover should show all commands, got %d of %d", |
| 316 | len(om.suggest), len(commands)) |
| 317 | } |
| 318 | // second Tab cycles (selection moves from 0 to 1) |
| 319 | mm2, _ := om.Update(tea.KeyMsg{Type: tea.KeyTab}) |
| 320 | if mm2.(Model).suggestIdx != 1 { |
| 321 | t.Fatalf("second Tab should cycle to idx 1, got %d", mm2.(Model).suggestIdx) |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | // TestPopoverTabCompletesUniquePrefix: with one match, Tab completes the name |
| 326 | // and, because /models takes args, appends a space that flips the popover into |
nothing calls this directly
no test coverage detected