aboutsummaryrefslogtreecommitdiff
path: root/test/segments/dir.spec
diff options
context:
space:
mode:
Diffstat (limited to 'test/segments/dir.spec')
-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 3a6af649..ef27e160 100755
--- a/test/segments/dir.spec
+++ b/test/segments/dir.spec
@@ -292,6 +292,31 @@ function testChangingDirPathSeparator() {
unset POWERLEVEL9K_DIR_PATH_SEPARATOR
}
+function testHomeFolderAbbreviation() {
+ local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION
+ local dir=$PWD
+
+ cd ~/
+ # default
+ POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
+ assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
+
+ # substituted
+ POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
+ assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)"
+
+ cd /tmp
+ # default
+ POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
+ assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
+
+ # substituted
+ POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
+ assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
+
+ cd "$dir"
+}
+
function testOmittingFirstCharacterWorks() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_FOLDER_ICON='folder-icon'
@@ -381,4 +406,25 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncat
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
+function testTruncateToUniqueWorks() {
+ POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
+ POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+ POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique'
+ mkdir -p /tmp/powerlevel9k-test/adam/devl
+ mkdir -p /tmp/powerlevel9k-test/alice/devl
+ mkdir -p /tmp/powerlevel9k-test/alice/docs
+ mkdir -p /tmp/powerlevel9k-test/bob/docs
+ cd /tmp/powerlevel9k-test/alice/devl
+
+ assertEquals "%K{blue} %F{black}txXxpxXxalxXxde %k%F{blue}%f " "$(build_left_prompt)"
+
+ cd -
+ rm -fr /tmp/powerlevel9k-test
+ unset POWERLEVEL9K_DIR_PATH_SEPARATOR
+ unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER
+ unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
+ unset POWERLEVEL9K_SHORTEN_STRATEGY
+}
+
source shunit2/source/2.1/src/shunit2