(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestScrollOffset_FollowsCursorDown(t *testing.T) { |
| 34 | app := newTestApp(makeStories(20), 120, 20) |
| 35 | listHeight := app.storiesListHeight() |
| 36 | if listHeight <= 0 { |
| 37 | t.Fatalf("expected positive listHeight, got %d", listHeight) |
| 38 | } |
| 39 | |
| 40 | // Navigate down past the visible range |
| 41 | for i := 0; i < listHeight+3; i++ { |
| 42 | if app.selectedIndex < len(app.prd.UserStories)-1 { |
| 43 | app.selectedIndex++ |
| 44 | app.adjustStoriesScroll() |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // Selected index should be past the first screen |
| 49 | if app.selectedIndex <= listHeight { |
| 50 | t.Errorf("expected selectedIndex > %d, got %d", listHeight, app.selectedIndex) |
| 51 | } |
| 52 | |
| 53 | // Scroll offset should have followed |
| 54 | if app.storiesScrollOffset == 0 { |
| 55 | t.Error("expected storiesScrollOffset > 0 after scrolling down past visible range") |
| 56 | } |
| 57 | |
| 58 | // Selected index should be visible |
| 59 | if app.selectedIndex < app.storiesScrollOffset || app.selectedIndex >= app.storiesScrollOffset+listHeight { |
| 60 | t.Errorf("selectedIndex %d not visible in scroll window [%d, %d)", app.selectedIndex, app.storiesScrollOffset, app.storiesScrollOffset+listHeight) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func TestScrollOffset_FollowsCursorUp(t *testing.T) { |
| 65 | app := newTestApp(makeStories(20), 120, 20) |
nothing calls this directly
no test coverage detected