| ... | ... |
@@ -5,21 +5,35 @@ require 'ttytest' |
| 5 | 5 |
class FzyTest < Minitest::Test |
| 6 | 6 |
FZY_PATH = File.expand_path('../../../fzy', __FILE__)
|
| 7 | 7 |
|
| 8 |
+ def setup |
|
| 9 |
+ # fzy is fast. |
|
| 10 |
+ # This is never hit in a (passing) test suite, but helps speed up development |
|
| 11 |
+ TTYtest.default_max_wait_time = 0.2 |
|
| 12 |
+ end |
|
| 13 |
+ |
|
| 8 | 14 |
def test_empty_list |
| 9 | 15 |
@tty = TTYtest.driver.new_terminal(%{echo placeholder;echo -n "" | fzy})
|
| 10 | 16 |
@tty.assert_row(0, 'placeholder') |
| 11 | 17 |
@tty.assert_row(1, '>') |
| 12 | 18 |
@tty.assert_row(2, '') |
| 19 |
+ @tty.assert_cursor_position(y: 1, x: 2) |
|
| 13 | 20 |
|
| 14 | 21 |
@tty.send_keys('t')
|
| 15 | 22 |
@tty.assert_row(0, 'placeholder') |
| 16 | 23 |
@tty.assert_row(1, '> t') |
| 17 | 24 |
@tty.assert_row(2, '') |
| 25 |
+ @tty.assert_cursor_position(y: 1, x: 3) |
|
| 18 | 26 |
|
| 19 | 27 |
@tty.send_keys('z')
|
| 20 | 28 |
@tty.assert_row(0, 'placeholder') |
| 21 | 29 |
@tty.assert_row(1, '> tz') |
| 22 | 30 |
@tty.assert_row(2, '') |
| 31 |
+ @tty.assert_cursor_position(y: 1, x: 4) |
|
| 32 |
+ |
|
| 33 |
+ @tty.send_keys("\r")
|
|
| 34 |
+ @tty.assert_row(0, 'placeholder') |
|
| 35 |
+ @tty.assert_row(1, 'tz') |
|
| 36 |
+ @tty.assert_cursor_position(y: 2, x: 0) |
|
| 23 | 37 |
end |
| 24 | 38 |
|
| 25 | 39 |
def test_one_item |
| ... | ... |
@@ -28,18 +42,26 @@ class FzyTest < Minitest::Test |
| 28 | 42 |
@tty.assert_row(1, '>') |
| 29 | 43 |
@tty.assert_row(2, 'test') |
| 30 | 44 |
@tty.assert_row(3, '') |
| 45 |
+ @tty.assert_cursor_position(y: 1, x: 2) |
|
| 31 | 46 |
|
| 32 | 47 |
@tty.send_keys('t')
|
| 33 | 48 |
@tty.assert_row(0, 'placeholder') |
| 34 | 49 |
@tty.assert_row(1, '> t') |
| 35 | 50 |
@tty.assert_row(2, 'test') |
| 36 | 51 |
@tty.assert_row(3, '') |
| 52 |
+ @tty.assert_cursor_position(y: 1, x: 3) |
|
| 37 | 53 |
|
| 38 | 54 |
@tty.send_keys('z')
|
| 39 | 55 |
@tty.assert_row(0, 'placeholder') |
| 40 | 56 |
@tty.assert_row(1, '> tz') |
| 41 | 57 |
@tty.assert_row(2, '') |
| 42 | 58 |
@tty.assert_row(3, '') |
| 59 |
+ @tty.assert_cursor_position(y: 1, x: 4) |
|
| 60 |
+ |
|
| 61 |
+ @tty.send_keys("\r")
|
|
| 62 |
+ @tty.assert_row(0, 'placeholder') |
|
| 63 |
+ @tty.assert_row(1, 'tz') |
|
| 64 |
+ @tty.assert_cursor_position(y: 2, x: 0) |
|
| 43 | 65 |
end |
| 44 | 66 |
|
| 45 | 67 |
def test_two_items |
| ... | ... |
@@ -49,17 +71,25 @@ class FzyTest < Minitest::Test |
| 49 | 71 |
@tty.assert_row(2, 'test') |
| 50 | 72 |
@tty.assert_row(3, 'foo') |
| 51 | 73 |
@tty.assert_row(4, '') |
| 74 |
+ @tty.assert_cursor_position(y: 1, x: 2) |
|
| 52 | 75 |
|
| 53 | 76 |
@tty.send_keys('t')
|
| 54 | 77 |
@tty.assert_row(0, 'placeholder') |
| 55 | 78 |
@tty.assert_row(1, '> t') |
| 56 | 79 |
@tty.assert_row(2, 'test') |
| 57 | 80 |
@tty.assert_row(3, '') |
| 81 |
+ @tty.assert_cursor_position(y: 1, x: 3) |
|
| 58 | 82 |
|
| 59 | 83 |
@tty.send_keys('z')
|
| 60 | 84 |
@tty.assert_row(0, 'placeholder') |
| 61 | 85 |
@tty.assert_row(1, '> tz') |
| 62 | 86 |
@tty.assert_row(2, '') |
| 63 | 87 |
@tty.assert_row(3, '') |
| 88 |
+ @tty.assert_cursor_position(y: 1, x: 4) |
|
| 89 |
+ |
|
| 90 |
+ @tty.send_keys("\r")
|
|
| 91 |
+ @tty.assert_row(0, 'placeholder') |
|
| 92 |
+ @tty.assert_row(1, 'tz') |
|
| 93 |
+ @tty.assert_cursor_position(y: 2, x: 0) |
|
| 64 | 94 |
end |
| 65 | 95 |
end |