fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit df6101c6c01f4c148a3d0a726258323c02fa62ea parent 51a6e55b87eceed426a8eb120ac57de473a437e6 Author: John Hawthorn <john.hawthorn@gmail.com> Date: Sat, 7 Oct 2017 21:32:15 -0700 Add acceptance test for moving text cursor Diffstat:
| M | test/acceptance/acceptance_test.rb | | | 34 | ++++++++++++++++++++++++++++------ |
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/test/acceptance/acceptance_test.rb b/test/acceptance/acceptance_test.rb @@ -5,12 +5,6 @@ require 'ttytest' class FzyTest < Minitest::Test FZY_PATH = File.expand_path('../../../fzy', __FILE__) - def setup - # fzy is fast. - # This is never hit in a (passing) test suite, but helps speed up development - TTYtest.default_max_wait_time = 0.2 - end - def test_empty_list @tty = TTYtest.new_terminal(%{echo placeholder;echo -n "" | #{FZY_PATH}}) @tty.assert_cursor_position(y: 1, x: 2) @@ -288,6 +282,34 @@ class FzyTest < Minitest::Test @tty.assert_matches "before\nfoo\nafter" end + def test_moving_text_cursor + @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}; echo after}) + @tty.send_keys("br") + @tty.assert_matches "> br\nbar" + @tty.assert_cursor_position(y: 0, x: 4) + + @tty.send_keys("\e[D") # left + @tty.assert_cursor_position(y: 0, x: 3) + @tty.assert_matches "> br\nbar" + @tty.send_keys("a") + @tty.assert_cursor_position(y: 0, x: 4) + @tty.assert_matches "> bar\nbar" + + @tty.send_keys(ctrl("A")) # Ctrl-A + @tty.assert_cursor_position(y: 0, x: 2) + @tty.assert_matches "> bar\nbar" + @tty.send_keys("foo") + @tty.assert_cursor_position(y: 0, x: 5) + @tty.assert_matches "> foobar" + + @tty.send_keys(ctrl("E")) # Ctrl-E + @tty.assert_cursor_position(y: 0, x: 8) + @tty.assert_matches "> foobar" + @tty.send_keys("baz") # Ctrl-E + @tty.assert_cursor_position(y: 0, x: 11) + @tty.assert_matches "> foobarbaz" + end + # More info; # https://github.com/jhawthorn/fzy/issues/42 # https://cirw.in/blog/bracketed-paste