diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2018-06-07 00:52:15 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2018-06-07 00:52:15 +0300 |
commit | 154e9230339e85009407b01e4aff076a3d76efa9 (patch) | |
tree | a2d210af3347fadaec3c7eb47ac700821bc83096 /test | |
parent | 45ae15370063568fe326ab9eadc4bac6d974179a (diff) | |
parent | 111d152d48cc92229cb523a992a0ecee740381e7 (diff) |
Merge remote-tracking branch 'floor114/next' into staging_065
Diffstat (limited to 'test')
-rwxr-xr-x | test/segments/vcs.spec | 80 |
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 |