Repository: junegunn/fzf
File: test/test_core.rb (Ruby)

Code before:
      tmux.send_keys query
      tmux.until { |lines| assert lines.any_include?("> #{query}".strip) }
      tmux.until do |lines|
        assert_match(/ 9998 9999 10000$/, lines[-3])
        assert_equal(1, lines[-3].scan('XX').size)
      end
    end
  end

  def test_freeze_right_exceed_range_with_freeze_left
    tmux.send_keys %[seq 10000 | tr "\n" ' ' | #{FZF} --freeze-left 3  --freeze-right 100000 --ellipsis XX], :Enter
    tmux.until do |lines|
      assert_match(/^> 1 2 3XX.*9998 9999 10000$/, lines[-3])
      assert_equal(1, lines[-3].scan('XX').size)
    end
  end

  def test_freeze_right_with_ellipsis_and_scrolling
    tmux.send_keys "{ seq 30; ruby -e 'print \"g\"*1000, \"\\n\"'; seq 32 100; } | #{FZF} --ellipsis='...' --freeze-right 1", :Enter
    tmux.until { |lines| assert_equal '  100/100', lines[-2] }
    tmux.send_keys(*Array.new(30) { :Up })
    tmux.until do |lines|
      line = lines.find { |l| l.start_with?('>') }
      assert_match(/> \.\.\.g+$/, line)
    end
    tmux.send_keys :Up
    tmux.until do |lines|
      line = lines.find { |l| l.start_with?('>') }
      assert_match(/^> 32\s*$/, line)
    end
  end

  def test_backward_eof
    tmux.send_keys "echo foo | #{FZF} --bind 'backward-eof:reload(seq 100)'", :Enter
    tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }
    tmux.send_keys 'x'
    tmux.until { |lines| lines.item_count == 1 && lines.match_count == 0 }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines.item_count == 100 && lines.match_count == 100 }
  end

  def test_change_prompt
    tmux.send_keys "#{FZF} --bind 'a:change-prompt(a> ),b:change-prompt:b> ' --query foo", :Enter
    tmux.until { |lines| assert_equal '> foo', lines[-1] }
    tmux.send_keys 'a'
    tmux.until { |lines| assert_equal 'a> foo', lines[-1] }
    tmux.send_keys 'b'
    tmux.until { |lines| assert_equal 'b> foo', lines[-1] }
  end

Review comment (suggestion):
Thanks, but I think this doesn't necessarily cause scrolling.

How about triggering `offset-up` action?

```sh
{ seq 6; ruby -e 'print "g"*1000, "\n"'; seq 8 100; } |
  fzf --ellipsis 777 --freeze-right 1 --scroll-off 0 --bind a:offset-up
````

- Press `a` 6 times, and see if there's a line starting with `> 777ggg`
- And there's only one line that ends with `g`

Code after:
      tmux.send_keys query
      tmux.until { |lines| assert lines.any_include?("> #{query}".strip) }
      tmux.until do |lines|
        assert_match(/ 9998 9999 10000$/, lines[-3])
        assert_equal(1, lines[-3].scan('XX').size)
      end
    end
  end

  def test_freeze_right_exceed_range_with_freeze_left
    tmux.send_keys %[seq 10000 | tr "\n" ' ' | #{FZF} --freeze-left 3  --freeze-right 100000 --ellipsis XX], :Enter
    tmux.until do |lines|
      assert_match(/^> 1 2 3XX.*9998 9999 10000$/, lines[-3])
      assert_equal(1, lines[-3].scan('XX').size)
    end
  end

  def test_freeze_right_with_ellipsis_and_scrolling
    tmux.send_keys "{ seq 6; ruby -e 'print \"g\"*1000, \"\\n\"'; seq 8 100; } | #{FZF} --ellipsis='777' --freeze-right 1 --scroll-off 0 --bind a:offset-up", :Enter
    tmux.until { |lines| assert_equal '  100/100', lines[-2] }
    tmux.send_keys(*Array.new(6) { :a })
    tmux.until do |lines|
      assert_match(/> 777g+$/, lines[-3])
      assert_equal 1, lines.count { |l| l.end_with?('g') }
    end
  end

  def test_backward_eof
    tmux.send_keys "echo foo | #{FZF} --bind 'backward-eof:reload(seq 100)'", :Enter
    tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }
    tmux.send_keys 'x'
    tmux.until { |lines| lines.item_count == 1 && lines.match_count == 0 }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines.item_count == 100 && lines.match_count == 100 }
  end

  def test_change_prompt
    tmux.send_keys "#{FZF} --bind 'a:change-prompt(a> ),b:change-prompt:b> ' --query foo", :Enter
    tmux.until { |lines| assert_equal '> foo', lines[-1] }
    tmux.send_keys 'a'
    tmux.until { |lines| assert_equal 'a> foo', lines[-1] }
    tmux.send_keys 'b'
    tmux.until { |lines| assert_equal 'b> foo', lines[-1] }
  end

  def test_select_deselect
    tmux.send_keys "seq 3 | #{FZF} --multi --bind up:deselect+up,down:select+down", :Enter
    tmux.until { |lines| assert_equal 3, lines.match_count }
    tmux.send_keys :Tab