MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestScrollOffset_FollowsCursorDown

Function TestScrollOffset_FollowsCursorDown

internal/tui/dashboard_test.go:33–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func 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
64func TestScrollOffset_FollowsCursorUp(t *testing.T) {
65 app := newTestApp(makeStories(20), 120, 20)

Callers

nothing calls this directly

Calls 4

newTestAppFunction · 0.85
makeStoriesFunction · 0.85
storiesListHeightMethod · 0.80
adjustStoriesScrollMethod · 0.80

Tested by

no test coverage detected