Skip to content

Commit

Permalink
chore: fixing commandline not available in CI environment
Browse files Browse the repository at this point in the history
  • Loading branch information
y3owk1n committed Jan 6, 2024
1 parent 3128881 commit 7abda31
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/_test_fzf_cmd_history.fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,40 @@ function setup_mocked_fzf
end
end

# Variable to capture the output of _fzf_cmd_history
set selected_command_output

# Function to override echo and capture the output
function echo -e
set selected_command_output $argv[1]
end

# Test _fzf_cmd_history without options
setup_mocked_history
set selected_command (echo "command1" | _fzf_cmd_history)
set selected_command_without_equals (string replace '=' '' $selected_command)
set selected_command_without_equals (string replace '=' '' $selected_command_output)
@test "selected command is correct" "$selected_command_without_equals" = command1

# Test _fzf_cmd_history with custom prompt name
setup_mocked_history
set selected_command (echo "command2" | _fzf_cmd_history --prompt-name "CustomPrompt")
set selected_command_without_equals (string replace '=' '' $selected_command)
set selected_command_without_equals (string replace '=' '' $selected_command_output)
@test "selected command is correct with custom prompt name" "$selected_command_without_equals" = command2
@test "prompt name in fzf is correct" $FZF_PROMPT_NAME = CustomPrompt

# Test _fzf_cmd_history with allow-execute option
setup_mocked_history
setup_mocked_fzf
set selected_command (echo "command3" | _fzf_cmd_history --allow-execute)
set selected_command_without_equals (string replace '=' '' $selected_command)
set selected_command_without_equals (string replace '=' '' $selected_command_output)
@test "selected command is correct with allow-execute option" "$selected_command_without_equals" = command3
@test "prompt name in fzf is correct" $FZF_PROMPT_NAME = "Command History"

# Test _fzf_cmd_history with both prompt name and allow-execute options
setup_mocked_history
setup_mocked_fzf
set selected_command (echo "command4" | _fzf_cmd_history --prompt-name "CustomPrompt" --allow-execute)
set selected_command_without_equals (string replace '=' '' $selected_command)
set selected_command_without_equals (string replace '=' '' $selected_command_output)
@test "selected command is correct with both options" "$selected_command_without_equals" = command4
@test "prompt name in fzf is correct" $FZF_PROMPT_NAME = CustomPrompt

Expand Down

0 comments on commit 7abda31

Please sign in to comment.