package tui import ( "testing" "github.com/lwoodard/rtsp-streamer/internal/config" ) func TestCellAtMouse(t *testing.T) { m := &model{ cfg: &config.Config{Layouts: []config.Layout{{Name: "g", Grid: "3x3"}}}, editLayout: 0, } cases := []struct { x, y int wantCol, wRow int ok bool }{ {1, 3, 0, 0, true}, // first content row, first cell {12, 3, 1, 0, true}, // second column (x past the divider at 11) {1, 6, 0, 1, true}, // second grid row {23, 9, 2, 2, true}, // third column, third row {1, 1, 0, 0, false}, // in the title/blank header area {1, 12, 0, 0, false}, // below the 3x3 grid } for _, tc := range cases { col, row, ok := m.cellAtMouse(tc.x, tc.y) if ok != tc.ok || (ok && (col != tc.wantCol || row != tc.wRow)) { t.Errorf("cellAtMouse(%d,%d) = (%d,%d,%v), want (%d,%d,%v)", tc.x, tc.y, col, row, ok, tc.wantCol, tc.wRow, tc.ok) } } }