diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-02-02 01:48:52 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-02-02 02:23:47 +0900 |
| commit | 32234be7a271196b62689974bf2002034f7e712e (patch) | |
| tree | f4ccbb62e4b8780c1fddf8116374ceea0f36bfa0 /test | |
| parent | 178b49832e09a78a9f8f5ce1647d5f36b667a097 (diff) | |
| download | fzf-32234be7a271196b62689974bf2002034f7e712e.tar.gz | |
FZF_KEY enhancements
* 'enter' instead of 'ctrl-m'
* 'space' instead of ' '
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_core.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_core.rb b/test/test_core.rb index 4b8a2cbc..bcd6e9d1 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -1607,4 +1607,49 @@ class TestCore < TestInteractive assert_equal 4, lines.match_count end end + + def test_env_vars + def to_vars(lines) + lines.select { it.start_with?('FZF_') }.to_h do + key, val = it.split('=', 2) + [key.to_sym, val] + end + end + + tmux.send_keys %(seq 100 | #{FZF} --multi --reverse --preview-window up,noborder --preview 'env | grep ^FZF_ | sort' --no-input --bind enter:show-input+refresh-preview,space:disable-search+refresh-preview), :Enter + expected = { + FZF_TOTAL_COUNT: '100', + FZF_MATCH_COUNT: '100', + FZF_SELECT_COUNT: '0', + FZF_ACTION: 'start', + FZF_KEY: '', + FZF_POS: '1', + FZF_QUERY: '', + FZF_PROMPT: '>', + FZF_INPUT_STATE: 'hidden' + } + tmux.until do |lines| + assert_equal expected, to_vars(lines).slice(*expected.keys) + end + tmux.send_keys :Enter + tmux.until do |lines| + expected.merge!(FZF_INPUT_STATE: 'enabled', FZF_ACTION: 'show-input', FZF_KEY: 'enter') + assert_equal expected, to_vars(lines).slice(*expected.keys) + end + tmux.send_keys :Tab, :Tab + tmux.until do |lines| + expected.merge!(FZF_ACTION: 'toggle-down', FZF_KEY: 'tab', FZF_POS: '3', FZF_SELECT_COUNT: '2') + assert_equal expected, to_vars(lines).slice(*expected.keys) + end + tmux.send_keys '99' + tmux.until do |lines| + expected.merge!(FZF_ACTION: 'char', FZF_KEY: '9', FZF_QUERY: '99', FZF_MATCH_COUNT: '1', FZF_POS: '1') + assert_equal expected, to_vars(lines).slice(*expected.keys) + end + tmux.send_keys :Space + tmux.until do |lines| + expected.merge!(FZF_INPUT_STATE: 'disabled', FZF_ACTION: 'disable-search', FZF_KEY: 'space') + assert_equal expected, to_vars(lines).slice(*expected.keys) + end + end end |
