diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-12-28 01:27:17 -0800 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-12-28 01:30:54 -0800 |
commit | c79aafceb523f7766e407da8bc3a6e0bbcf18e34 (patch) | |
tree | b1e474c2dbadf7db99545f1b01881ea66027059f /test | |
parent | ce550897510d70f273b83b8b627e7cd97b6f080f (diff) |
Add integration test for query editing
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/integration_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
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 |