diff options
Diffstat (limited to 'test/segments')
-rwxr-xr-x | test/segments/command_execution_time.spec | 12 | ||||
-rwxr-xr-x | test/segments/dir.spec | 196 | ||||
-rwxr-xr-x | test/segments/go_version.spec | 2 | ||||
-rwxr-xr-x | test/segments/kubecontext.spec | 38 | ||||
-rwxr-xr-x | test/segments/rust_version.spec | 2 |
5 files changed, 232 insertions, 18 deletions
diff --git a/test/segments/command_execution_time.spec b/test/segments/command_execution_time.spec index 09738859..e8be508f 100755 --- a/test/segments/command_execution_time.spec +++ b/test/segments/command_execution_time.spec @@ -28,7 +28,7 @@ function testCommandExecutionTimeThresholdCouldBeChanged() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 _P9K_COMMAND_DURATION=2.03 - assertEquals "%K{red} %F{226%}Dur%f %F{226}2.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -40,7 +40,7 @@ function testCommandExecutionTimeThresholdCouldBeSetToZero() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 _P9K_COMMAND_DURATION=0.03 - assertEquals "%K{red} %F{226%}Dur%f %F{226}0.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.03 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -53,7 +53,7 @@ function testCommandExecutionTimePrecisionCouldBeChanged() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4 _P9K_COMMAND_DURATION=0.0001 - assertEquals "%K{red} %F{226%}Dur%f %F{226}0.0001 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -66,7 +66,7 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 _P9K_COMMAND_DURATION=23.5001 - assertEquals "%K{red} %F{226%}Dur%f %F{226}23 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -77,7 +77,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) _P9K_COMMAND_DURATION=180 - assertEquals "%K{red} %F{226%}Dur%f %F{226}03:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -87,7 +87,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) _P9K_COMMAND_DURATION=7200 - assertEquals "%K{red} %F{226%}Dur%f %F{226}02:00:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 97bc857c..e8bbaf93 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -18,6 +18,16 @@ function tearDown() { unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } +function testDirPathAbsoluteWorks() { + POWERLEVEL9K_DIR_PATH_ABSOLUTE=true + + cd ~ + assertEquals "%K{blue} %F{black}/home/travis %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_ABSOLUTE +} + function testTruncateFoldersWorks() { POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' @@ -93,6 +103,60 @@ function testTruncationFromRightWorks() { unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testTruncateToLastWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last" + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}123456789 %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset POWERLEVEL9K_SHORTEN_STRATEGY +} + +function testTruncateToFirstAndLastWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last" + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset POWERLEVEL9K_SHORTEN_STRATEGY +} + +function testTruncateAbsoluteWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute" + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}…89 %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset POWERLEVEL9K_SHORTEN_STRATEGY +} + function testTruncationFromRightWithEmptyDelimiter() { POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_DELIMITER="" @@ -448,4 +512,136 @@ function testTruncateToUniqueWorks() { unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testBoldHomeDirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + cd ~ + + assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldHomeSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + mkdir -p ~/powerlevel9k-test + cd ~/powerlevel9k-test + + assertEquals "%K{blue} %F{black}~/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr ~/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldRootDirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + cd / + + assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldRootSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + cd /tmp + + assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldRootSubSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + mkdir -p /tmp/powerlevel9k-test + cd /tmp/powerlevel9k-test + + assertEquals "%K{blue} %F{black}/tmp/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testHighlightHomeWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + cd ~ + + assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightHomeSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + mkdir -p ~/powerlevel9k-test + cd ~/powerlevel9k-test + + assertEquals "%K{blue} %F{black}~/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr ~/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightRootWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + cd / + + assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightRootSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + cd /tmp + + assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightRootSubSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + mkdir /tmp/powerlevel9k-test + cd /tmp/powerlevel9k-test + + assertEquals "%K{blue} %F{black}/tmp/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testDirSeparatorColorHomeSubdirWorks() { + POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + mkdir -p ~/powerlevel9k-test + cd ~/powerlevel9k-test + + assertEquals "%K{blue} %F{black}~%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr ~/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND +} + +function testDirSeparatorColorRootSubSubdirWorks() { + POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + mkdir -p /tmp/powerlevel9k-test + cd /tmp/powerlevel9k-test + + assertEquals "%K{blue} %F{black}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND +} + source shunit2/source/2.1/src/shunit2 diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec index 2aac460b..347ba4c0 100755 --- a/test/segments/go_version.spec +++ b/test/segments/go_version.spec @@ -40,7 +40,7 @@ function testGo() { PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" - assertEquals "%K{green} %F{255%}%f %F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{grey93%}%f %F{grey93}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" unset POWERLEVEL9K_GO_ICON unset PWD diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec index eaaa2300..4f1d2c5e 100755 --- a/test/segments/kubecontext.spec +++ b/test/segments/kubecontext.spec @@ -18,11 +18,19 @@ function mockKubectl() { ;; 'config') case "$2" in - 'current-context') - echo 'minikube' - ;; - 'get-contexts') - echo '* minikube minikube minikube ' + 'view') + case "$3" in + '-o=jsonpath={.current-context}') + echo 'minikube' + ;; + '-o=jsonpath={.contexts'*) + echo '' + ;; + *) + echo "Mock value missed" + exit 1 + ;; + esac ;; esac ;; @@ -36,11 +44,21 @@ function mockKubectlOtherNamespace() { ;; 'config') case "$2" in - 'current-context') - echo 'minikube' - ;; - 'get-contexts') - echo '* minikube minikube minikube kube-system' + 'view') + case "$3" in + # Get Current Context + '-o=jsonpath={.current-context}') + echo 'minikube' + ;; + # Get current namespace + '-o=jsonpath={.contexts'*) + echo 'kube-system' + ;; + *) + echo "Mock value missed" + exit 1 + ;; + esac ;; esac ;; diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 49b06bcf..a9668671 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -19,7 +19,7 @@ function testRust() { alias rustc=mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias rustc |