mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
add test for preventing right overscroll
This commit is contained in:
@@ -14,7 +14,7 @@ func TestNew(t *testing.T) {
|
|||||||
m := New(10, 10)
|
m := New(10, 10)
|
||||||
|
|
||||||
if !m.initialized {
|
if !m.initialized {
|
||||||
t.Errorf("on create by New Model should be initialized")
|
t.Errorf("on create by New, Model should be initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.horizontalStep != defaultHorizontalStep {
|
if m.horizontalStep != defaultHorizontalStep {
|
||||||
@@ -357,3 +357,25 @@ func TestVisibleLines(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRightOverscroll(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
t.Run("prevent right overscroll", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
content := "Content is short"
|
||||||
|
m := New(len(content)+1, 5)
|
||||||
|
m.SetContent(content)
|
||||||
|
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
m.MoveRight()
|
||||||
|
}
|
||||||
|
|
||||||
|
visibleLines := m.visibleLines()
|
||||||
|
visibleLine := visibleLines[0]
|
||||||
|
|
||||||
|
if visibleLine != content {
|
||||||
|
t.Error("visible line should stay the same as content")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user