From 4b74f882c79600e4a988146d037eabf1fc484c7d Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 27 Jan 2025 02:08:52 +0900 Subject: [test] Prefer match_count over item_count match_count can lag behind item_count and can cause intermittent failures. --- test/test_core.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/test_core.rb') diff --git a/test/test_core.rb b/test/test_core.rb index 75cf3d77..21e400d4 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -111,7 +111,7 @@ class TestCore < TestInteractive def test_multi_max tmux.send_keys "seq 1 10 | #{FZF} -m 3 --bind A:select-all,T:toggle-all --preview 'echo [{+}]/{}'", :Enter - tmux.until { |lines| assert_equal 10, lines.item_count } + tmux.until { |lines| assert_equal 10, lines.match_count } tmux.send_keys '1' tmux.until do |lines| @@ -177,7 +177,7 @@ class TestCore < TestInteractive def test_multi_action tmux.send_keys "seq 10 | #{FZF} --bind 'a:change-multi,b:change-multi(3),c:change-multi(xxx),d:change-multi(0)'", :Enter - tmux.until { |lines| assert_equal 10, lines.item_count } + tmux.until { |lines| assert_equal 10, lines.match_count } tmux.until { |lines| assert lines[-2]&.start_with?(' 10/10 ') } tmux.send_keys 'a' tmux.until { |lines| assert lines[-2]&.start_with?(' 10/10 (0)') } @@ -1176,7 +1176,7 @@ class TestCore < TestInteractive def test_unbind_rebind tmux.send_keys "seq 100 | #{FZF} --bind 'c:clear-query,d:unbind(c,d),e:rebind(c,d)'", :Enter - tmux.until { |lines| assert_equal 100, lines.item_count } + tmux.until { |lines| assert_equal 100, lines.match_count } tmux.send_keys 'ab' tmux.until { |lines| assert_equal '> ab', lines[-1] } tmux.send_keys 'c' @@ -1189,7 +1189,7 @@ class TestCore < TestInteractive def test_scroll_off tmux.send_keys "seq 1000 | #{FZF} --scroll-off=3 --bind l:last", :Enter - tmux.until { |lines| assert_equal 1000, lines.item_count } + tmux.until { |lines| assert_equal 1000, lines.match_count } height = tmux.until { |lines| lines }.first.to_i tmux.send_keys :PgUp tmux.until do |lines| @@ -1208,7 +1208,7 @@ class TestCore < TestInteractive def test_scroll_off_large tmux.send_keys "seq 1000 | #{FZF} --scroll-off=9999", :Enter - tmux.until { |lines| assert_equal 1000, lines.item_count } + tmux.until { |lines| assert_equal 1000, lines.match_count } height = tmux.until { |lines| lines }.first.to_i tmux.send_keys :PgUp tmux.until { |lines| assert_equal "> #{height}", lines[height / 2].strip } @@ -1253,7 +1253,7 @@ class TestCore < TestInteractive def test_result_event tmux.send_keys '(echo 0; seq 10) | fzf --bind "result:pos(2)"', :Enter - tmux.until { |lines| assert_equal 11, lines.item_count } + tmux.until { |lines| assert_equal 11, lines.match_count } tmux.until { |lines| assert_includes lines, '> 1' } tmux.send_keys '9' tmux.until { |lines| assert_includes lines, '> 9' } @@ -1397,7 +1397,7 @@ class TestCore < TestInteractive def test_prev_next_selected tmux.send_keys 'seq 10 | fzf --multi --bind ctrl-n:next-selected,ctrl-p:prev-selected', :Enter - tmux.until { |lines| assert_equal 10, lines.item_count } + tmux.until { |lines| assert_equal 10, lines.match_count } tmux.send_keys :BTab, :BTab, :Up, :BTab tmux.until { |lines| assert_equal 3, lines.select_count } tmux.send_keys 'C-n' @@ -1530,7 +1530,7 @@ class TestCore < TestInteractive def test_height_range_with_exit_0 tmux.send_keys "seq 10 | #{FZF} --height ~10% --exit-0", :Enter - tmux.until { |lines| assert_equal 10, lines.item_count } + tmux.until { |lines| assert_equal 10, lines.match_count } tmux.send_keys :c tmux.until { |lines| assert_equal 0, lines.match_count } end @@ -1542,7 +1542,7 @@ class TestCore < TestInteractive skip('CTRL-DELETE is not properly handled in GitHub Actions environment') end tmux.send_keys "seq 100 | #{FZF} --bind 'ctrl-delete:up+up,shift-delete:down,focus:transform-prompt:echo [{}]'", :Enter - tmux.until { |lines| assert_equal 100, lines.item_count } + tmux.until { |lines| assert_equal 100, lines.match_count } tmux.send_keys 'C-Delete' tmux.until { |lines| assert_equal '[3]', lines[-1] } tmux.send_keys 'S-Delete' -- cgit v1.2.3