add test for preventing right overscroll

This commit is contained in:
Roman Suvorov
2024-12-18 22:35:57 +01:00
parent f6b7762e47
commit 9c0bc5c7da
+23 -1
View File
@@ -14,7 +14,7 @@ func TestNew(t *testing.T) {
m := New(10, 10)
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 {
@@ -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")
}
})
}