summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2017-02-05 16:34:56 +0300
committerDominik Ritter <dritter03@googlemail.com>2017-02-05 16:53:31 +0300
commit8e99944797b171b84bd347cc8b9c065d7298d25c (patch)
tree01719cf15b16a66689a8da435ade0fce54e4f801
parented9d18f1de5d5e0142f40bea452ddc3749967baa (diff)
Add test for truncate_with_folder_marker truncation strategy
-rwxr-xr-xtest/segments/dir.spec46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/segments/dir.spec b/test/segments/dir.spec
index 840a298b..0f253ac3 100755
--- a/test/segments/dir.spec
+++ b/test/segments/dir.spec
@@ -71,6 +71,52 @@ function testTruncationFromRightWorks() {
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
+function testTruncateWithFolderMarkerWorks() {
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+ POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
+
+ local BASEFOLDER=/tmp/powerlevel9k-test
+ local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
+ mkdir -p $FOLDER
+ # Setup folder marker
+ touch $BASEFOLDER/1/12/.shorten_folder_marker
+ cd $FOLDER
+ assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)"
+
+ cd -
+ rm -fr $BASEFOLDER
+ unset BASEFOLDER
+ unset FOLDER
+ unset POWERLEVEL9K_SHORTEN_STRATEGY
+ unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+}
+
+function testTruncateWithFolderMarkerWithChangedFolderMarker() {
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+ POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
+ POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx'
+
+ local BASEFOLDER=/tmp/powerlevel9k-test
+ local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
+ mkdir -p $FOLDER
+ # Setup folder marker
+ touch $BASEFOLDER/1/12/.xxx
+ cd $FOLDER
+ assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)"
+
+ cd -
+ rm -fr $BASEFOLDER
+ unset BASEFOLDER
+ unset FOLDER
+ unset POWERLEVEL9K_SHORTEN_FOLDER_MARKER
+ unset POWERLEVEL9K_SHORTEN_STRATEGY
+ unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+}
+
function testHomeFolderDetectionWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_HOME_ICON='home-icon'