From c79aafceb523f7766e407da8bc3a6e0bbcf18e34 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 28 Dec 2016 01:27:17 -0800 Subject: Add integration test for query editing --- test/integration/integration_test.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/integration/integration_test.rb b/test/integration/integration_test.rb index 7f4f975..5237c20 100644 --- 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 -- cgit v1.2.3