summaryrefslogtreecommitdiff
path: root/test/segments/vcs.spec
diff options
context:
space:
mode:
Diffstat (limited to 'test/segments/vcs.spec')
-rwxr-xr-xtest/segments/vcs.spec86
1 files changed, 83 insertions, 3 deletions
diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec
index 4467145e..f6474f61 100755
--- a/test/segments/vcs.spec
+++ b/test/segments/vcs.spec
@@ -21,7 +21,7 @@ function testColorOverridingForCleanStateWorks() {
cd $FOLDER
git init 1>/dev/null
- assertEquals "%K{white} %F{cyan}master %k%F{white}%f " "$(build_left_prompt)"
+ assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
@@ -47,7 +47,7 @@ function testColorOverridingForModifiedStateWorks() {
git commit -m "test" 1>/dev/null
echo "test" > testfile
- assertEquals "%K{yellow} %F{red}master ● %k%F{yellow}%f " "$(build_left_prompt)"
+ assertEquals "%K{yellow} %F{red} master ● %k%F{yellow}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
@@ -68,7 +68,7 @@ function testColorOverridingForUntrackedStateWorks() {
git init 1>/dev/null
touch testfile
- assertEquals "%K{yellow} %F{cyan}master ? %k%F{yellow}%f " "$(build_left_prompt)"
+ assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
@@ -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