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

Function TestScrollOffset_FollowsCursorUp

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

Source from the content-addressed store, hash-verified

62}
63
64func 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
97func TestScrollOffset_NoScrollWhenAllFit(t *testing.T) {
98 // 3 stories in a 20-tall terminal — all should fit

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