(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func TestScrollOffset_FollowsCursorUp(t *testing.T) { |
| 65 | app := newTestApp(makeStories(20), 120, 20) |
| 66 | listHeight := app.storiesListHeight() |
| 67 | |
| 68 | // Move down first |
| 69 | for i := 0; i < listHeight+5; i++ { |
| 70 | if app.selectedIndex < len(app.prd.UserStories)-1 { |
| 71 | app.selectedIndex++ |
| 72 | app.adjustStoriesScroll() |
| 73 | } |
| 74 | } |
| 75 | savedOffset := app.storiesScrollOffset |
| 76 | |
| 77 | // Now navigate back up past the scroll offset |
| 78 | for i := 0; i < listHeight+5; i++ { |
| 79 | if app.selectedIndex > 0 { |
| 80 | app.selectedIndex-- |
| 81 | if app.selectedIndex < app.storiesScrollOffset { |
| 82 | app.storiesScrollOffset = app.selectedIndex |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Should be back at top |
| 88 | if app.selectedIndex != 0 { |
| 89 | t.Errorf("expected selectedIndex 0, got %d", app.selectedIndex) |
| 90 | } |
| 91 | if app.storiesScrollOffset != 0 { |
| 92 | t.Errorf("expected storiesScrollOffset 0, got %d", app.storiesScrollOffset) |
| 93 | } |
| 94 | _ = savedOffset |
| 95 | } |
| 96 | |
| 97 | func TestScrollOffset_NoScrollWhenAllFit(t *testing.T) { |
| 98 | // 3 stories in a 20-tall terminal — all should fit |
nothing calls this directly
no test coverage detected