Skip to content
Myr

Add test cases for --select-1 and --exit-0

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent be5c176 · Browse files · 1 file+38 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+38 added−7 removed

  • tests:+38 added−7 removed

1 file+38 added−7 removed

modified:test/test_go.rb+38 added-7 removed
1 unmodified line
2# encoding: utf-834require 'minitest/autorun'56class NilClass7 def include? str8 false9 end10end1112class Tmux13 TEMPNAME = '/tmp/fzf-test.txt'1415 attr_reader :win
68 unmodified lines
84 def tempname85 '/tmp/output'86 end8788 def readtemp89 waited = 090 while waited < 591 begin92 return File.read(tempname)93 rescue94 sleep 0.195 waited += 0.196 end97 end98 raise "failed to read tempfile"99 end100101 def setup102 ENV.delete 'FZF_DEFAULT_OPTS'103 ENV.delete 'FZF_DEFAULT_COMMAND'104 @prev = Tmux.current
25 unmodified lines
130 assert_equal '> 391', lines[-1]131132 tmux.send_keys :Enter133 tmux.close115 assert_equal '1391', File.read(tempname).chomp134 assert_equal '1391', readtemp.chomp135 end136137 def test_fzf_default_command138 tmux.send_keys "FZF_DEFAULT_COMMAND='echo hello' fzf > #{tempname}", :Enter139 tmux.until { |lines| lines.last =~ /^>/ }140141 tmux.send_keys :Enter142 tmux.close124 assert_equal 'hello', File.read(tempname).chomp143 assert_equal 'hello', readtemp.chomp144 end145146 def test_key_bindings147 tmux.send_keys "fzf -q 'foo bar foo-bar'", :Enter
69 unmodified lines
217 'C-K', 'C-K', 'C-K', 'C-K', :BTab, :BTab, # 5, 6218 :PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7219 tmux.until { |lines| lines[-2].include? '(6)' }220 tmux.send_keys "C-M"202 assert_equal %w[3 2 5 6 8 7], File.read(tempname).split($/)221 assert_equal %w[3 2 5 6 8 7], readtemp.split($/)222 tmux.close223 end224225 def test_with_nth
1 unmodified line
227 tmux.send_keys "(echo ' 1st 2nd 3rd/';228 echo ' first second third/') |229 fzf #{"--multi" if multi} -x --nth 2 --with-nth 2,-1,1 > #{tempname}",230 :Enter212 tmux.until { |lines| lines[-2] && lines[-2].include?('2/2') }231 tmux.until { |lines| lines[-2].include?('2/2') }232233 # Transformed list234 lines = tmux.capture235 assert_equal ' second third/first', lines[-4]
1 unmodified line
237238 # However, the output must not be transformed239 if multi240 tmux.send_keys :BTab, :BTab, :Enter222 assert_equal [' 1st 2nd 3rd/', ' first second third/'], File.read(tempname).split($/)241 assert_equal [' 1st 2nd 3rd/', ' first second third/'], readtemp.split($/)242 else243 tmux.send_keys '^', '3'244 tmux.until { |lines| lines[-2].include?('1/2') }245 tmux.send_keys :Enter246 tmux.send_keys 'echo -n done', :Enter247 tmux.until { |lines| lines[-1].include?('done') }229 assert_equal [' 1st 2nd 3rd/'], File.read(tempname).split($/)248 assert_equal [' 1st 2nd 3rd/'], readtemp.split($/)249 end250 end251 end252
7 unmodified lines
260 end261 tmux.send_keys :Enter262 tmux.send_keys 'echo -n done', :Enter263 tmux.until { |lines| lines[-1].include?('done') }245 assert_equal '100', File.read(tempname).chomp264 assert_equal '100', readtemp.chomp265 end266 end267268 def test_select_1269 tmux.send_keys "seq 1 100 | fzf --with-nth ..,.. --print-query -q 5555 -1 > #{tempname} && echo -n done", :Enter270 tmux.until { |lines| lines[-1].include?('done') }271 assert_equal ['5555', '55'], readtemp.split($/)272 end273274 def test_exit_0275 tmux.send_keys "seq 1 100 | fzf --with-nth ..,.. --print-query -q 555555 -0 > #{tempname} && echo -n done", :Enter276 tmux.until { |lines| lines[-1].include?('done') }277 assert_equal ['555555'], readtemp.split($/)278 end279end280