summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-01-17 11:20:00 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-01-17 11:20:17 +0900
commit4c3ae847b6e134d39ddfdf466088f670ecb158f1 (patch)
treed18c8f173e111351ba7aba885c9b67c94ec8852f /test
parent5c0dc79ffae4c2da24ff77c4aea370287491693d (diff)
Add test case for --with-nth + --multi
Diffstat (limited to 'test')
-rw-r--r--test/test_go.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/test_go.rb b/test/test_go.rb
index 26d7a04d..0b39ea84 100644
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -124,7 +124,7 @@ class TestGoFZF < MiniTest::Unit::TestCase
assert_equal 'hello', File.read(tempname).chomp
end
- def test_fzf_prompt
+ def test_key_bindings
tmux.send_keys "fzf -q 'foo bar foo-bar'", :Enter
tmux.until { |lines| lines.last =~ /^>/ }
@@ -190,7 +190,7 @@ class TestGoFZF < MiniTest::Unit::TestCase
tmux.close
end
- def test_fzf_multi_order
+ def test_multi_order
tmux.send_keys "seq 1 10 | fzf --multi > #{tempname}", :Enter
tmux.until { |lines| lines.last =~ /^>/ }
@@ -202,5 +202,31 @@ class TestGoFZF < MiniTest::Unit::TestCase
assert_equal %w[3 2 5 6 8 7], File.read(tempname).split($/)
tmux.close
end
+
+ def test_with_nth
+ [true, false].each do |multi|
+ tmux.send_keys "(echo ' 1st 2nd 3rd/';
+ echo ' first second third/') |
+ fzf #{"--multi" if multi} -x --nth 2 --with-nth 2,-1,1 > #{tempname}",
+ :Enter
+ tmux.until { |lines| lines[-2] && lines[-2].include?('2/2') }
+
+ # Transformed list
+ lines = tmux.capture
+ assert_equal ' second third/first', lines[-4]
+ assert_equal '> 2nd 3rd/1st', lines[-3]
+
+ # However, the output must not be transformed
+ if multi
+ tmux.send_keys :BTab, :BTab, :Enter
+ assert_equal [' 1st 2nd 3rd/', ' first second third/'], File.read(tempname).split($/)
+ else
+ tmux.send_keys '^', '3'
+ tmux.until { |lines| lines[-2].include?('1/2') }
+ tmux.send_keys :Enter
+ assert_equal [' 1st 2nd 3rd/'], File.read(tempname).split($/)
+ end
+ end
+ end
end