fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 656744dc0aaf00c99aed4b5873df8a161cc0b8db parent 664a3689e4c2f5e61931e162537792216c856439 Author: John Hawthorn <john.hawthorn@gmail.com> Date: Wed, 28 Dec 2016 01:27:17 -0800 Add integration test for query editing Diffstat:
| M | test/integration/integration_test.rb | | | 31 | +++++++++++++++++++++++++++++++ |
1 file changed, 31 insertions(+), 0 deletions(-)
diff --git a/test/integration/integration_test.rb b/test/integration/integration_test.rb @@ -92,4 +92,35 @@ class FzyTest < Minitest::Test @tty.assert_row(1, 'tz') @tty.assert_cursor_position(y: 2, x: 0) end + + def ctrl(key) + ((key.upcase.ord) - ('A'.ord) + 1).chr + end + + def test_editing + @tty = TTYtest.driver.new_terminal(%{echo placeholder;echo -n "test\nfoo" | fzy}) + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, '>') + @tty.assert_cursor_position(y: 1, x: 2) + + @tty.send_keys("foo bar baz") + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, '> foo bar baz') + @tty.assert_cursor_position(y: 1, x: 13) + + @tty.send_keys(ctrl('H')) + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, '> foo bar ba') + @tty.assert_cursor_position(y: 1, x: 12) + + @tty.send_keys(ctrl('W')) + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, '> foo bar') + @tty.assert_cursor_position(y: 1, x: 10) + + @tty.send_keys(ctrl('U')) + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, '>') + @tty.assert_cursor_position(y: 1, x: 2) + end end