mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
71 lines
1.2 KiB
Bash
71 lines
1.2 KiB
Bash
#!/usr/bin/env zsh
|
|
|
|
source "${0:a:h}/../test_helper.zsh"
|
|
|
|
oneTimeSetUp() {
|
|
source_autosuggestions
|
|
}
|
|
|
|
setUp() {
|
|
BUFFER=''
|
|
POSTDISPLAY=''
|
|
CURSOR=0
|
|
}
|
|
|
|
tearDown() {
|
|
restore _zsh_autosuggest_invoke_original_widget
|
|
}
|
|
|
|
testCursorMovesOutOfBuffer() {
|
|
BUFFER='ec'
|
|
POSTDISPLAY='ho hello'
|
|
CURSOR=1
|
|
|
|
stub_and_eval \
|
|
_zsh_autosuggest_invoke_original_widget \
|
|
'CURSOR=5; LBUFFER="echo "; RBUFFER="hello"'
|
|
|
|
_zsh_autosuggest_partial_accept 'original-widget'
|
|
|
|
assertTrue \
|
|
'original widget not invoked' \
|
|
'stub_called _zsh_autosuggest_invoke_original_widget'
|
|
|
|
assertEquals \
|
|
'BUFFER was not modified correctly' \
|
|
'echo ' \
|
|
"$BUFFER"
|
|
|
|
assertEquals \
|
|
'POSTDISPLAY was not modified correctly' \
|
|
'hello' \
|
|
"$POSTDISPLAY"
|
|
}
|
|
|
|
testCursorStaysInBuffer() {
|
|
BUFFER='echo hello'
|
|
POSTDISPLAY=' world'
|
|
CURSOR=1
|
|
|
|
stub_and_eval \
|
|
_zsh_autosuggest_invoke_original_widget \
|
|
'CURSOR=5; LBUFFER="echo "; RBUFFER="hello"'
|
|
|
|
_zsh_autosuggest_partial_accept 'original-widget'
|
|
|
|
assertTrue \
|
|
'original widget not invoked' \
|
|
'stub_called _zsh_autosuggest_invoke_original_widget'
|
|
|
|
assertEquals \
|
|
'BUFFER was modified' \
|
|
'echo hello' \
|
|
"$BUFFER"
|
|
|
|
assertEquals \
|
|
'POSTDISPLAY was modified' \
|
|
' world' \
|
|
"$POSTDISPLAY"
|
|
}
|
|
|
|
run_tests "$0"
|