Add vcs branch name truncating.
This commit is contained in:
parent
4c919f1a2b
commit
111d152d48
3 changed files with 118 additions and 0 deletions
|
@ -78,4 +78,84 @@ function testColorOverridingForUntrackedStateWorks() {
|
|||
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||
}
|
||||
|
||||
function testBranchNameTruncatingShortenLength() {
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
POWERLEVEL9K_VCS_SHORTEN_LENGTH=6
|
||||
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3
|
||||
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
|
||||
|
||||
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
git init 1>/dev/null
|
||||
touch testfile
|
||||
|
||||
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
|
||||
|
||||
POWERLEVEL9K_VCS_SHORTEN_LENGTH=3
|
||||
assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
|
||||
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_LENGTH
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY
|
||||
}
|
||||
|
||||
function testBranchNameTruncatingMinLength() {
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
POWERLEVEL9K_VCS_SHORTEN_LENGTH=3
|
||||
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=6
|
||||
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
|
||||
|
||||
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
git init 1>/dev/null
|
||||
touch testfile
|
||||
|
||||
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
|
||||
|
||||
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7
|
||||
|
||||
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
|
||||
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_LENGTH
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY
|
||||
}
|
||||
|
||||
function testBranchNameTruncatingShortenStrategy() {
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
POWERLEVEL9K_VCS_SHORTEN_LENGTH=3
|
||||
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3
|
||||
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
|
||||
|
||||
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
git init 1>/dev/null
|
||||
touch testfile
|
||||
|
||||
assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)"
|
||||
|
||||
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle"
|
||||
|
||||
assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
|
||||
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_LENGTH
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
|
||||
unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY
|
||||
}
|
||||
|
||||
source shunit2/source/2.1/src/shunit2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue