aboutsummaryrefslogtreecommitdiff
path: root/test/segments/vcs.spec
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2018-06-25 16:41:54 +0300
committerGitHub <noreply@github.com>2018-06-25 16:41:54 +0300
commit348617040b6985f21e1140c451747a8005249fb2 (patch)
treea9f44d94add0c8a83cac53dc904404b8e2e5100a /test/segments/vcs.spec
parent7234d52ebd76b6b89e172ac5b19339f0a37ab596 (diff)
parentbda3171237e83ab7fd47d5b2fa6c2d3f44f02e92 (diff)
Merge pull request #859 from dritter/staging_065
Merging the staging branch for 0.6.5!
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