Browse code

Add acceptance tests for --lines and --prompt

John Hawthorn authored on 08/02/2017 02:14:09
Showing 1 changed files

... ...
@@ -200,4 +200,32 @@ class FzyTest < Minitest::Test
200 200
     @tty.send_keys("\e[B\r") # and back up
201 201
     @tty.assert_matches "foo"
202 202
   end
203
+
204
+  def test_lines
205
+    @tty = TTYtest.new_terminal(%{seq 10 | #{FZY_PATH}})
206
+    @tty.assert_matches ">\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
207
+
208
+    @tty = TTYtest.new_terminal(%{seq 20 | #{FZY_PATH}})
209
+    @tty.assert_matches ">\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
210
+
211
+    @tty = TTYtest.new_terminal(%{seq 10 | #{FZY_PATH} -l 5})
212
+    @tty.assert_matches ">\n1\n2\n3\n4\n5"
213
+
214
+    @tty = TTYtest.new_terminal(%{seq 10 | #{FZY_PATH} --lines=5})
215
+    @tty.assert_matches ">\n1\n2\n3\n4\n5"
216
+  end
217
+
218
+  def test_prompt
219
+    @tty = TTYtest.new_terminal(%{echo -n "" | #{FZY_PATH}})
220
+    @tty.send_keys("foo")
221
+    @tty.assert_matches '> foo'
222
+
223
+    @tty = TTYtest.new_terminal(%{echo -n "" | #{FZY_PATH} -p 'C:\\'})
224
+    @tty.send_keys("foo")
225
+    @tty.assert_matches 'C:\foo'
226
+
227
+    @tty = TTYtest.new_terminal(%{echo -n "" | #{FZY_PATH} --prompt="foo bar "})
228
+    @tty.send_keys("baz")
229
+    @tty.assert_matches "foo bar baz"
230
+  end
203 231
 end