Browse code

Add tests for arrow keys

John Hawthorn authored on 14/01/2017 04:52:55
Showing 1 changed files

... ...
@@ -174,4 +174,30 @@ class FzyTest < Minitest::Test
174 174
     @tty.assert_matches ''
175 175
     @tty.assert_cursor_position(y: 0, x: 0)
176 176
   end
177
+
178
+  def test_down_arrow
179
+    @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}})
180
+    @tty.assert_matches ">\nfoo\nbar"
181
+    @tty.send_keys("\e[A\r")
182
+    @tty.assert_matches "bar"
183
+
184
+    @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}})
185
+    @tty.assert_matches ">\nfoo\nbar"
186
+    @tty.send_keys("\eOA\r")
187
+    @tty.assert_matches "bar"
188
+  end
189
+
190
+  def test_up_arrow
191
+    @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}})
192
+    @tty.assert_matches ">\nfoo\nbar"
193
+    @tty.send_keys("\e[A")   # first down
194
+    @tty.send_keys("\e[B\r") # and back up
195
+    @tty.assert_matches "foo"
196
+
197
+    @tty = TTYtest.new_terminal(%{echo -n "foo\nbar" | #{FZY_PATH}})
198
+    @tty.assert_matches ">\nfoo\nbar"
199
+    @tty.send_keys("\eOA")   # first down
200
+    @tty.send_keys("\e[B\r") # and back up
201
+    @tty.assert_matches "foo"
202
+  end
177 203
 end