| ... | ... |
@@ -92,4 +92,35 @@ class FzyTest < Minitest::Test |
| 92 | 92 |
@tty.assert_row(1, 'tz') |
| 93 | 93 |
@tty.assert_cursor_position(y: 2, x: 0) |
| 94 | 94 |
end |
| 95 |
+ |
|
| 96 |
+ def ctrl(key) |
|
| 97 |
+ ((key.upcase.ord) - ('A'.ord) + 1).chr
|
|
| 98 |
+ end |
|
| 99 |
+ |
|
| 100 |
+ def test_editing |
|
| 101 |
+ @tty = TTYtest.driver.new_terminal(%{echo placeholder;echo -n "test\nfoo" | fzy})
|
|
| 102 |
+ @tty.assert_row(0, 'placeholder') |
|
| 103 |
+ @tty.assert_row(1, '>') |
|
| 104 |
+ @tty.assert_cursor_position(y: 1, x: 2) |
|
| 105 |
+ |
|
| 106 |
+ @tty.send_keys("foo bar baz")
|
|
| 107 |
+ @tty.assert_row(0, 'placeholder') |
|
| 108 |
+ @tty.assert_row(1, '> foo bar baz') |
|
| 109 |
+ @tty.assert_cursor_position(y: 1, x: 13) |
|
| 110 |
+ |
|
| 111 |
+ @tty.send_keys(ctrl('H'))
|
|
| 112 |
+ @tty.assert_row(0, 'placeholder') |
|
| 113 |
+ @tty.assert_row(1, '> foo bar ba') |
|
| 114 |
+ @tty.assert_cursor_position(y: 1, x: 12) |
|
| 115 |
+ |
|
| 116 |
+ @tty.send_keys(ctrl('W'))
|
|
| 117 |
+ @tty.assert_row(0, 'placeholder') |
|
| 118 |
+ @tty.assert_row(1, '> foo bar') |
|
| 119 |
+ @tty.assert_cursor_position(y: 1, x: 10) |
|
| 120 |
+ |
|
| 121 |
+ @tty.send_keys(ctrl('U'))
|
|
| 122 |
+ @tty.assert_row(0, 'placeholder') |
|
| 123 |
+ @tty.assert_row(1, '>') |
|
| 124 |
+ @tty.assert_cursor_position(y: 1, x: 2) |
|
| 125 |
+ end |
|
| 95 | 126 |
end |