More tests for completion
parent
b37da4e1f0
commit
cd578f8772
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
_bash-it-comp-enable-disable()
|
||||
{
|
||||
local enable_disable_args="alias plugin completion"
|
||||
local enable_disable_args="alias completion plugin"
|
||||
COMPREPLY=( $(compgen -W "${enable_disable_args}" -- ${cur}) )
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,16 +43,25 @@ function local_teardown {
|
|||
}
|
||||
|
||||
function __check_completion () {
|
||||
# Get the parameters as a single value
|
||||
COMP_LINE=$*
|
||||
|
||||
# Get the parameters as an array
|
||||
eval set -- "$@"
|
||||
COMP_WORDS=("$@")
|
||||
|
||||
# Get the parameters as a single value
|
||||
COMP_LINE=$*
|
||||
|
||||
# Index of the cursor in the line
|
||||
COMP_POINT=${#COMP_LINE}
|
||||
|
||||
# Get the last character of the line that was entered
|
||||
COMP_LAST=$((${COMP_POINT} - 1))
|
||||
|
||||
# If the last character was a space...
|
||||
if [[ ${COMP_LINE:$COMP_LAST} = ' ' ]]; then
|
||||
# ...then add an empty array item
|
||||
COMP_WORDS+=('')
|
||||
fi
|
||||
|
||||
# Word index of the last word
|
||||
COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 ))
|
||||
|
||||
|
|
@ -68,6 +77,17 @@ function __check_completion () {
|
|||
assert_line "0" "vagrant vault vim"
|
||||
}
|
||||
|
||||
@test "completion bash-it: disable - show options" {
|
||||
run __check_completion 'bash-it disable '
|
||||
assert_line "0" "alias completion plugin"
|
||||
}
|
||||
|
||||
@test "completion bash-it: disable - show options a" {
|
||||
run __check_completion 'bash-it disable a'
|
||||
|
||||
assert_line "0" "alias"
|
||||
}
|
||||
|
||||
@test "completion bash-it: disable - provide nothing when atom is not enabled" {
|
||||
run __check_completion 'bash-it disable alias ato'
|
||||
assert_line "0" ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue