diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2022-09-08 01:01:22 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2022-09-28 23:22:31 +0900 |
commit | 22cbd9fa58512ffdcc975bab37a55467d5e10968 (patch) | |
tree | bddf8d579d8fe88abc4a6014f1a0e936d48be7c7 /test | |
parent | 984049586a5e5409131e4cb4600115f4a6b9c669 (diff) |
Implement height range (--height ~[VALUE][%])
Close #2953
Diffstat (limited to 'test')
-rwxr-xr-x | test/test_go.rb | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/test_go.rb b/test/test_go.rb index 6371e0e2..bb6a4c8d 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -2245,6 +2245,93 @@ class TestGoFZF < TestBase tmux.until { |lines| assert_equal 1, lines.match_count } tmux.until { |lines| assert_match(/^> SNIPSNIP.*SNIPSNIP$/, lines[-3]) } end + + def assert_block(expected, lines) + cols = expected.lines.map(&:chomp).map(&:length).max + actual = lines.reverse.take(expected.lines.length).reverse.map { _1[0, cols].rstrip + "\n" }.join + assert_equal expected, actual + end + + def test_height_range_fit + tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border', :Enter + expected = <<~OUTPUT + ╭────────── + │ 3 + │ 2 + │ > 1 + │ > < 3/3 + ╰────────── + OUTPUT + tmux.until { assert_block(expected, _1) } + end + + def test_height_range_fit_preview_above + tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border --preview "seq {}" --preview-window up,60%', :Enter + expected = <<~OUTPUT + ╭────────── + │ ╭──────── + │ │ 1 + │ │ + │ │ + │ │ + │ ╰──────── + │ 3 + │ 2 + │ > 1 + │ > < 3/3 + ╰────────── + OUTPUT + tmux.until { assert_block(expected, _1) } + end + + def test_height_range_fit_preview_above_alternative + tmux.send_keys 'seq 3 | fzf --height ~100% --border=sharp --preview "seq {}" --preview-window up,40%,border-bottom --padding 1 --exit-0 --header hello --header-lines=2', :Enter + expected = <<~OUTPUT + ┌───────── + │ + │ 1 + │ 2 + │ 3 + │ ─────── + │ > 3 + │ 2 + │ 1 + │ hello + │ 1/1 + │ > + │ + └───────── + OUTPUT + tmux.until { assert_block(expected, _1) } + end + + def test_height_range_fit_preview_left + tmux.send_keys "seq 3 | fzf --height ~100% --border=vertical --preview 'seq {}' --preview-window left,5,border-right --padding 1 --exit-0 --header $'hello\\nworld' --header-lines=2", :Enter + expected = <<~OUTPUT + │ + │ 1 │> 3 + │ 2 │ 2 + │ 3 │ 1 + │ │ hello + │ │ world + │ │ 1/1 + │ │> + │ + OUTPUT + tmux.until { assert_block(expected, _1) } + end + + def test_height_range_overflow + tmux.send_keys 'seq 100 | fzf --height ~5 --info=inline --border', :Enter + expected = <<~OUTPUT + ╭────────────── + │ 2 + │ > 1 + │ > < 100/100 + ╰────────────── + OUTPUT + tmux.until { assert_block(expected, _1) } + end end module TestShell |