Skip to content

Commit 5d356ed

Browse files
committed
Split up test_file_completion
1 parent 73ca5b5 commit 5d356ed

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

test/test_go.rb

+29-19
Original file line numberDiff line numberDiff line change
@@ -1715,9 +1715,8 @@ def test_ctrl_r_abort
17151715
module CompletionTest
17161716
include TestShell
17171717

1718-
def test_file_completion
1718+
def test_file_completion1
17191719
FileUtils.touch(('1'..'100').to_a)
1720-
FileUtils.touch(['no~such~user', 'foobar', File.expand_path('~/.fzf-home')])
17211720
tmux.prepare
17221721
tmux.send_keys('cat 10**', :Tab)
17231722
tmux.until { |lines| lines.match_count == 2 }
@@ -1727,9 +1726,24 @@ def test_file_completion
17271726
tmux.until do |lines|
17281727
lines[-1] == '$ cat 10 100'
17291728
end
1729+
end
17301730

1731-
# ~USERNAME**<TAB>
1732-
tmux.send_keys('C-u')
1731+
# **<TAB>
1732+
def test_file_completion2
1733+
FileUtils.touch('foobar')
1734+
tmux.prepare
1735+
tmux.send_keys('cat **', :Tab)
1736+
tmux.until { |lines| lines.match_count > 0 }
1737+
tmux.send_keys('foobar$')
1738+
tmux.until { |lines| lines.match_count == 1 }
1739+
tmux.send_keys(:Enter)
1740+
tmux.until { |lines| lines[-1] == '$ cat foobar' }
1741+
end
1742+
1743+
# ~USERNAME**<TAB>
1744+
def test_file_completion_username
1745+
FileUtils.touch(File.expand_path('~/.fzf-home'))
1746+
tmux.prepare
17331747
tmux.send_keys("cat ~#{ENV['USER']}**", :Tab)
17341748
tmux.until { |lines| lines.match_count > 0 }
17351749
tmux.send_keys("'.fzf-home")
@@ -1738,30 +1752,26 @@ def test_file_completion
17381752
tmux.until do |lines|
17391753
lines[-1] =~ %r{cat .*/\.fzf-home}
17401754
end
1755+
ensure
1756+
File.unlink(File.expand_path('~/.fzf-home'))
1757+
end
17411758

1742-
# ~INVALID_USERNAME**<TAB>
1743-
tmux.send_keys('C-u')
1759+
# ~INVALID_USERNAME**<TAB>
1760+
def test_file_completion_invalid_username
1761+
FileUtils.touch('no~such~user')
1762+
tmux.prepare
17441763
tmux.send_keys('cat ~such**', :Tab)
17451764
tmux.until { |lines| lines.any_include?('no~such~user') }
17461765
tmux.send_keys(:Enter)
17471766
tmux.until { |lines| lines[-1] == '$ cat no~such~user' }
1767+
end
17481768

1749-
# **<TAB>
1750-
tmux.send_keys('C-u')
1751-
tmux.send_keys('cat **', :Tab)
1752-
tmux.until { |lines| lines.match_count > 0 }
1753-
tmux.send_keys('foobar$')
1754-
tmux.until { |lines| lines.match_count == 1 }
1755-
tmux.send_keys(:Enter)
1756-
tmux.until { |lines| lines[-1] == '$ cat foobar' }
1757-
1758-
# Should include hidden files
1769+
# Should include hidden files
1770+
def test_file_completion_hidden
17591771
FileUtils.touch((1..100).map { |i| ".hidden-#{i}" })
1760-
tmux.send_keys('C-u')
1772+
tmux.prepare
17611773
tmux.send_keys('cat hidden**', :Tab)
17621774
tmux.until { |lines| lines.match_count == 100 && lines.any_include?('.hidden-') }
1763-
ensure
1764-
File.unlink(File.expand_path('~/.fzf-home'))
17651775
end
17661776

17671777
def test_file_completion_root

0 commit comments

Comments
 (0)