From 8b3d08d7a6e8eccc2997ccbf91a7e12d506196e5 Mon Sep 17 00:00:00 2001 From: elianiva Date: Wed, 24 Feb 2021 21:40:11 +0700 Subject: fix: scroll misbehaving + fixed jump to middle (#547) * fix: scroll misbehaving + fixed jump to middle * add test * fixx * fix nil --- lua/tests/automated/scroller_spec.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lua/tests') diff --git a/lua/tests/automated/scroller_spec.lua b/lua/tests/automated/scroller_spec.lua index bd202e8..c650aac 100644 --- a/lua/tests/automated/scroller_spec.lua +++ b/lua/tests/automated/scroller_spec.lua @@ -114,18 +114,16 @@ describe('scroller', function() describe('should give top, middle and bottom index', function() - it('should handle middle index', function() - eq(5, p_scroller.middle(nil, 11, nil)) - eq(10, p_scroller.middle(nil, 20, nil)) - eq(12, p_scroller.middle(nil, 25, nil)) - end) - it('should handle ascending', function() eq(0, p_scroller.top('ascending', 20, 1000)) eq(19, p_scroller.bottom('ascending', 20, 1000)) eq(0, p_scroller.top('ascending', 20, 10)) eq(9, p_scroller.bottom('ascending', 20, 10)) + + eq(5, p_scroller.middle('ascending', 11, 100)) + eq(10, p_scroller.middle('ascending', 20, 100)) + eq(12, p_scroller.middle('ascending', 25, 100)) end) it('should handle descending', function() @@ -134,6 +132,10 @@ describe('scroller', function() eq(10, p_scroller.top('descending', 20, 10)) eq(19, p_scroller.bottom('descending', 20, 10)) + + eq(25, p_scroller.middle('descending', 30, 10)) + eq(50, p_scroller.middle('descending', 60, 20)) + eq(105, p_scroller.middle('descending', 120, 30)) end) end) end) -- cgit v1.2.3