aboutsummaryrefslogtreecommitdiff
path: root/test/segments/vcs.spec
diff options
context:
space:
mode:
authorTaras Shpachenko <taras.shpachenko@onapp.com>2018-04-12 13:39:39 +0300
committerTaras Shpachenko <taras.shpachenko@onapp.com>2018-04-12 18:11:23 +0300
commit111d152d48cc92229cb523a992a0ecee740381e7 (patch)
tree7d6f348319ce3c6819b8a398c4ddfafa1a0773bd /test/segments/vcs.spec
parent4c919f1a2bca9d52271edebcbd5090423304afef (diff)
Add vcs branch name truncating.
Diffstat (limited to 'test/segments/vcs.spec')
-rwxr-xr-xtest/segments/vcs.spec80
1 files changed, 80 insertions, 0 deletions
diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec
index c33b564d..f6474f61 100755
--- a/test/segments/vcs.spec
+++ b/test/segments/vcs.spec
@@ -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