diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-12-28 01:10:42 -0800 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-12-28 01:27:24 -0800 |
commit | ce550897510d70f273b83b8b627e7cd97b6f080f (patch) | |
tree | 7461f37b2b11661091338a13a2403980270cfb48 /test | |
parent | 62862ec61d0dc48a44e13291f4ce3d3fcd4756ea (diff) |
Expand on integration test
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/Gemfile.lock | 2 | ||||
-rw-r--r-- | test/integration/integration_test.rb | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/test/integration/Gemfile.lock b/test/integration/Gemfile.lock index 0ad2eee..c0040c4 100644 --- a/test/integration/Gemfile.lock +++ b/test/integration/Gemfile.lock @@ -2,7 +2,7 @@ GEM remote: https://rubygems.org/ specs: minitest (5.10.1) - ttytest (0.1.0) + ttytest (0.2.0) PLATFORMS ruby diff --git a/test/integration/integration_test.rb b/test/integration/integration_test.rb index 21ba0f5..7f4f975 100644 --- a/test/integration/integration_test.rb +++ b/test/integration/integration_test.rb @@ -5,21 +5,35 @@ require 'ttytest' class FzyTest < Minitest::Test FZY_PATH = File.expand_path('../../../fzy', __FILE__) + def setup + # fzy is fast. + # This is never hit in a (passing) test suite, but helps speed up development + TTYtest.default_max_wait_time = 0.2 + end + def test_empty_list @tty = TTYtest.driver.new_terminal(%{echo placeholder;echo -n "" | fzy}) @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '>') @tty.assert_row(2, '') + @tty.assert_cursor_position(y: 1, x: 2) @tty.send_keys('t') @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '> t') @tty.assert_row(2, '') + @tty.assert_cursor_position(y: 1, x: 3) @tty.send_keys('z') @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '> tz') @tty.assert_row(2, '') + @tty.assert_cursor_position(y: 1, x: 4) + + @tty.send_keys("\r") + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, 'tz') + @tty.assert_cursor_position(y: 2, x: 0) end def test_one_item @@ -28,18 +42,26 @@ class FzyTest < Minitest::Test @tty.assert_row(1, '>') @tty.assert_row(2, 'test') @tty.assert_row(3, '') + @tty.assert_cursor_position(y: 1, x: 2) @tty.send_keys('t') @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '> t') @tty.assert_row(2, 'test') @tty.assert_row(3, '') + @tty.assert_cursor_position(y: 1, x: 3) @tty.send_keys('z') @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '> tz') @tty.assert_row(2, '') @tty.assert_row(3, '') + @tty.assert_cursor_position(y: 1, x: 4) + + @tty.send_keys("\r") + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, 'tz') + @tty.assert_cursor_position(y: 2, x: 0) end def test_two_items @@ -49,17 +71,25 @@ class FzyTest < Minitest::Test @tty.assert_row(2, 'test') @tty.assert_row(3, 'foo') @tty.assert_row(4, '') + @tty.assert_cursor_position(y: 1, x: 2) @tty.send_keys('t') @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '> t') @tty.assert_row(2, 'test') @tty.assert_row(3, '') + @tty.assert_cursor_position(y: 1, x: 3) @tty.send_keys('z') @tty.assert_row(0, 'placeholder') @tty.assert_row(1, '> tz') @tty.assert_row(2, '') @tty.assert_row(3, '') + @tty.assert_cursor_position(y: 1, x: 4) + + @tty.send_keys("\r") + @tty.assert_row(0, 'placeholder') + @tty.assert_row(1, 'tz') + @tty.assert_cursor_position(y: 2, x: 0) end end |