summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/integration_test.rb31
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