package ui import ( "testing" "time" "github.com/humdrum-tiv/sportsball/internal/model" ) // Up/Down must move by visual grid row (keeping column), not ±1 through the // flat list. With 3 cards in a 2-wide grid the rows are [[0,1],[2]]. func TestMoveCursorVertical(t *testing.T) { now := time.Now() a := App{ width: 80, // columns() => 80/(cardWidth+3) = 2 leagues: model.Leagues, filter: model.MLB, games: map[model.LeagueID][]model.Game{ model.MLB: { {ID: "g0", League: model.MLB, State: model.StatePre, Start: now}, {ID: "g1", League: model.MLB, State: model.StatePre, Start: now}, {ID: "g2", League: model.MLB, State: model.StatePre, Start: now}, }, }, } if c := a.columns(); c != 2 { t.Fatalf("expected 2 columns at width 80, got %d", c) } a.cursor = 1 // top-right (row0,col1) a.moveCursorVert(1) if a.cursor != 2 { // down → row1 only has col0, clamps to g2 t.Errorf("down from 1 = %d, want 2", a.cursor) } a.moveCursorVert(-1) // back up → row0 col0 if a.cursor != 0 { t.Errorf("up from 2 = %d, want 0", a.cursor) } }