summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/segments/dir.spec106
-rwxr-xr-xtest/segments/vcs.spec6
2 files changed, 109 insertions, 3 deletions
diff --git a/test/segments/dir.spec b/test/segments/dir.spec
index ce6869b7..b2991175 100755
--- a/test/segments/dir.spec
+++ b/test/segments/dir.spec
@@ -114,6 +114,112 @@ function testTruncateWithFolderMarkerWithChangedFolderMarker() {
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
}
+function testTruncateWithPackageNameWorks() {
+ local p9kFolder=$(pwd)
+ local BASEFOLDER=/tmp/powerlevel9k-test
+ local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
+ mkdir -p $FOLDER
+
+ cd /tmp/powerlevel9k-test
+ echo '
+{
+ "name": "My_Package"
+}
+' > package.json
+ # Unfortunately: The main folder must be a git repo..
+ git init &>/dev/null
+
+ # Go back to deeper folder
+ cd "${FOLDER}"
+
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+ POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
+
+ assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)"
+
+ # Go back
+ cd $p9kFolder
+ rm -fr $BASEFOLDER
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_SHORTEN_STRATEGY
+ unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
+}
+
+function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() {
+ local p9kFolder=$(pwd)
+ local BASEFOLDER=/tmp/powerlevel9k-test
+ local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
+ mkdir -p $FOLDER
+ cd $FOLDER
+
+ # Unfortunately: The main folder must be a git repo..
+ git init &>/dev/null
+
+ echo '
+{
+ "name": "My_Package"
+}
+' > package.json
+
+ # Create a subdir inside the repo
+ mkdir -p asdfasdf/qwerqwer
+
+ cd $BASEFOLDER
+ ln -s ${FOLDER} linked-repo
+
+ # Go to deep folder inside linked repo
+ cd linked-repo/asdfasdf/qwerqwer
+
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+ POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
+
+ assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)"
+
+ # Go back
+ cd $p9kFolder
+ rm -fr $BASEFOLDER
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_SHORTEN_STRATEGY
+ unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
+}
+
+function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() {
+ local p9kFolder=$(pwd)
+ local BASEFOLDER=/tmp/powerlevel9k-test
+ local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
+ mkdir -p $FOLDER
+ cd $FOLDER
+
+ # Unfortunately: The main folder must be a git repo..
+ git init &>/dev/null
+
+ echo '
+{
+ "name": "My_Package"
+}
+' > package.json
+
+ cd $BASEFOLDER
+ ln -s ${FOLDER} linked-repo
+
+ cd linked-repo/.git/refs/heads
+
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+ POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
+
+ assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)"
+
+ # Go back
+ cd $p9kFolder
+ rm -fr $BASEFOLDER
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_SHORTEN_STRATEGY
+ unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
+}
+
function testHomeFolderDetectionWorks() {
POWERLEVEL9K_HOME_ICON='home-icon'
diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec
index c33b564d..4467145e 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