From 8301d16cb20611501ef57afd95dd46e96bde2552 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 13 Jan 2017 20:52:55 -0800 Subject: Add tests for arrow keys --- test/acceptance/acceptance_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/acceptance') diff --git a/test/acceptance/acceptance_test.rb b/test/acceptance/acceptance_test.rb index aed795d..67a0ccf 100644 --- a/test/acceptance/acceptance_test.rb +++ b/test/acceptance/acceptance_test.rb @@ -174,4 +174,30 @@ class FzyTest < Minitest::Test @tty.assert_matches '' @tty.assert_cursor_position(y: 0, x: 0) end + + def test_down_arrow + @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}}) + @tty.assert_matches ">\nfoo\nbar" + @tty.send_keys("\e[A\r") + @tty.assert_matches "bar" + + @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}}) + @tty.assert_matches ">\nfoo\nbar" + @tty.send_keys("\eOA\r") + @tty.assert_matches "bar" + end + + def test_up_arrow + @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}}) + @tty.assert_matches ">\nfoo\nbar" + @tty.send_keys("\e[A") # first down + @tty.send_keys("\e[B\r") # and back up + @tty.assert_matches "foo" + + @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}}) + @tty.assert_matches ">\nfoo\nbar" + @tty.send_keys("\eOA") # first down + @tty.send_keys("\e[B\r") # and back up + @tty.assert_matches "foo" + end end -- cgit v1.2.3