Implement suggestion integration tests in RSpec + tmux
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source "${0:a:h}/../test_helper.zsh"
|
||||
|
||||
oneTimeSetUp() {
|
||||
source_autosuggestions
|
||||
}
|
||||
|
||||
testNoMatch() {
|
||||
set_history <<-'EOF'
|
||||
ls foo
|
||||
ls bar
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'foo' \
|
||||
''
|
||||
|
||||
assertSuggestion \
|
||||
'ls q' \
|
||||
''
|
||||
}
|
||||
|
||||
testBasicMatches() {
|
||||
set_history <<-'EOF'
|
||||
ls foo
|
||||
ls bar
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'ls f' \
|
||||
'ls foo'
|
||||
|
||||
assertSuggestion \
|
||||
'ls b' \
|
||||
'ls bar'
|
||||
}
|
||||
|
||||
testMostRecentMatch() {
|
||||
set_history <<-'EOF'
|
||||
ls foo
|
||||
cd bar
|
||||
ls baz
|
||||
cd quux
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'ls' \
|
||||
'ls baz'
|
||||
|
||||
assertSuggestion \
|
||||
'cd' \
|
||||
'cd quux'
|
||||
}
|
||||
|
||||
run_tests "$0"
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source "${0:a:h}/../test_helper.zsh"
|
||||
|
||||
oneTimeSetUp() {
|
||||
source_autosuggestions
|
||||
|
||||
ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd
|
||||
}
|
||||
|
||||
testNoMatch() {
|
||||
set_history <<-'EOF'
|
||||
ls foo
|
||||
ls bar
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'foo' \
|
||||
''
|
||||
|
||||
assertSuggestion \
|
||||
'ls q' \
|
||||
''
|
||||
}
|
||||
|
||||
testBasicMatches() {
|
||||
set_history <<-'EOF'
|
||||
ls foo
|
||||
ls bar
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'ls f' \
|
||||
'ls foo'
|
||||
|
||||
assertSuggestion \
|
||||
'ls b' \
|
||||
'ls bar'
|
||||
}
|
||||
|
||||
testMostRecentMatch() {
|
||||
set_history <<-'EOF'
|
||||
ls foo
|
||||
cd bar
|
||||
ls baz
|
||||
cd quux
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'ls' \
|
||||
'ls baz'
|
||||
|
||||
assertSuggestion \
|
||||
'cd' \
|
||||
'cd quux'
|
||||
}
|
||||
|
||||
testMatchMostRecentAfterPreviousCmd() {
|
||||
set_history <<-'EOF'
|
||||
echo what
|
||||
ls foo
|
||||
ls bar
|
||||
echo what
|
||||
ls baz
|
||||
ls quux
|
||||
echo what
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'ls' \
|
||||
'ls baz'
|
||||
}
|
||||
|
||||
run_tests "$0"
|
||||
@@ -1,102 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source "${0:a:h}/test_helper.zsh"
|
||||
|
||||
oneTimeSetUp() {
|
||||
source_autosuggestions
|
||||
}
|
||||
|
||||
assertBackslashSuggestion() {
|
||||
set_history <<-'EOF'
|
||||
echo "hello\nworld"
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'echo "hello\' \
|
||||
'echo "hello\nworld"'
|
||||
}
|
||||
|
||||
assertDoubleBackslashSuggestion() {
|
||||
set_history <<-'EOF'
|
||||
echo "\\"
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'echo "\\' \
|
||||
'echo "\\"'
|
||||
}
|
||||
|
||||
assertTildeSuggestion() {
|
||||
set_history <<-'EOF'
|
||||
cd ~/something
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'cd' \
|
||||
'cd ~/something'
|
||||
|
||||
assertSuggestion \
|
||||
'cd ~' \
|
||||
'cd ~/something'
|
||||
|
||||
assertSuggestion \
|
||||
'cd ~/s' \
|
||||
'cd ~/something'
|
||||
}
|
||||
|
||||
assertTildeSuggestionWithExtendedGlob() {
|
||||
setopt local_options extended_glob
|
||||
|
||||
assertTildeSuggestion
|
||||
}
|
||||
|
||||
assertParenthesesSuggestion() {
|
||||
set_history <<-'EOF'
|
||||
echo "$(ls foo)"
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'echo "$(' \
|
||||
'echo "$(ls foo)"'
|
||||
}
|
||||
|
||||
assertSquareBracketsSuggestion() {
|
||||
set_history <<-'EOF'
|
||||
echo "$history[123]"
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'echo "$history[' \
|
||||
'echo "$history[123]"'
|
||||
}
|
||||
|
||||
assertHashSuggestion() {
|
||||
set_history <<-'EOF'
|
||||
echo "#yolo"
|
||||
EOF
|
||||
|
||||
assertSuggestion \
|
||||
'echo "#' \
|
||||
'echo "#yolo"'
|
||||
}
|
||||
|
||||
testSpecialCharsForAllStrategies() {
|
||||
local strategies
|
||||
strategies=(
|
||||
"default"
|
||||
"match_prev_cmd"
|
||||
)
|
||||
|
||||
for s in $strategies; do
|
||||
ZSH_AUTOSUGGEST_STRATEGY="$s"
|
||||
|
||||
assertBackslashSuggestion
|
||||
assertDoubleBackslashSuggestion
|
||||
assertTildeSuggestion
|
||||
assertTildeSuggestionWithExtendedGlob
|
||||
assertParenthesesSuggestion
|
||||
assertSquareBracketsSuggestion
|
||||
done
|
||||
}
|
||||
|
||||
run_tests "$0"
|
||||
Reference in New Issue
Block a user