mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Add test for execute widget
This commit is contained in:
parent
8c3fdea75d
commit
125f48c7f2
1 changed files with 49 additions and 0 deletions
|
@ -177,6 +177,29 @@ testWidgetFunctionAcceptCursorNotAtEnd() {
|
|||
"$POSTDISPLAY"
|
||||
}
|
||||
|
||||
testWidgetFunctionExecute() {
|
||||
BUFFER="ec"
|
||||
POSTDISPLAY="ho hello"
|
||||
|
||||
stub _zsh_autosuggest_invoke_original_widget
|
||||
|
||||
_zsh_autosuggest_execute
|
||||
|
||||
assertTrue \
|
||||
"accept-line not invoked" \
|
||||
"stub_called_with _zsh_autosuggest_invoke_original_widget 'accept-line'"
|
||||
|
||||
assertEquals \
|
||||
"BUFFER was not modified" \
|
||||
"echo hello" \
|
||||
"$BUFFER"
|
||||
|
||||
assertEquals \
|
||||
"POSTDISPLAY was not cleared" \
|
||||
"" \
|
||||
"$POSTDISPLAY"
|
||||
}
|
||||
|
||||
testWidgetFunctionPartialAcceptCursorMovesOutOfBuffer() {
|
||||
BUFFER="ec"
|
||||
POSTDISPLAY="ho hello"
|
||||
|
@ -281,6 +304,32 @@ testWidgetClear() {
|
|||
"stub_called _zsh_autosuggest_highlight_apply"
|
||||
}
|
||||
|
||||
testWidgetExecute() {
|
||||
stub _zsh_autosuggest_highlight_reset
|
||||
stub _zsh_autosuggest_execute
|
||||
stub _zsh_autosuggest_highlight_apply
|
||||
|
||||
# Call the function pointed to by the widget since we can't call
|
||||
# the widget itself when zle is not active
|
||||
${widgets[autosuggest-execute]#*:} "original-widget"
|
||||
|
||||
assertTrue \
|
||||
"autosuggest-execute widget does not exist" \
|
||||
"zle -l autosuggest-execute"
|
||||
|
||||
assertTrue \
|
||||
"highlight_reset was not called" \
|
||||
"stub_called _zsh_autosuggest_highlight_reset"
|
||||
|
||||
assertTrue \
|
||||
"widget function was not called" \
|
||||
"stub_called _zsh_autosuggest_execute"
|
||||
|
||||
assertTrue \
|
||||
"highlight_apply was not called" \
|
||||
"stub_called _zsh_autosuggest_highlight_apply"
|
||||
}
|
||||
|
||||
testEscapeCommandPrefix() {
|
||||
assertEquals \
|
||||
"Did not escape single backslash" \
|
||||
|
|
Loading…
Reference in a new issue