diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-07-22 13:45:38 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-07-22 13:45:38 +0900 |
commit | f71ea5f3ea469489fc979ee3c0cd2622d011befd (patch) | |
tree | 83f60e4b82c0ef3f6ce90f988746bf801d69d5d6 /test | |
parent | f469c25730aaa711b8327be068514c944074cce4 (diff) |
Add test cases for header and fix corner cases
Diffstat (limited to 'test')
-rw-r--r-- | test/test_go.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/test_go.rb b/test/test_go.rb index 88dff86c..7effb5fb 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -648,6 +648,61 @@ class TestGoFZF < TestBase tmux.until { |lines| lines[-10].start_with? '>' } end + def test_header_lines + tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5'}", :Enter + 2.times do + tmux.until do |lines| + lines[-2].include?('/90') && + lines[-3] == ' 1' && + lines[-4] == ' 2' && + lines[-13] == '> 15' + end + tmux.send_keys :Down + end + tmux.send_keys :Enter + assert_equal '15', readonce.chomp + end + + def test_header_lines_reverse + tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5 --reverse'}", :Enter + 2.times do + tmux.until do |lines| + lines[1].include?('/90') && + lines[2] == ' 1' && + lines[3] == ' 2' && + lines[12] == '> 15' + end + tmux.send_keys :Up + end + tmux.send_keys :Enter + assert_equal '15', readonce.chomp + end + + def test_header_lines_overflow + tmux.send_keys "seq 100 | #{fzf '--header-lines=200'}", :Enter + tmux.until { |lines| lines[-2].include?('0/0') } + tmux.send_keys :Enter + assert_equal '', readonce.chomp + end + + def test_header_file + tmux.send_keys "seq 100 | #{fzf "--header-file <(head -5 #{__FILE__})"}", :Enter + header = File.readlines(__FILE__).take(5).map(&:strip) + tmux.until do |lines| + lines[-2].include?('100/100') && + lines[-7..-3].map(&:strip) == header + end + end + + def test_header_file_reverse + tmux.send_keys "seq 100 | #{fzf "--header-file <(head -5 #{__FILE__}) --reverse"}", :Enter + header = File.readlines(__FILE__).take(5).map(&:strip) + tmux.until do |lines| + lines[1].include?('100/100') && + lines[2..6].map(&:strip) == header + end + end + private def writelines path, lines File.unlink path while File.exists? path |