aboutsummaryrefslogtreecommitdiff
path: root/test/core
diff options
context:
space:
mode:
authorYang Tang <ytang@users.noreply.github.com>2018-10-12 18:29:50 +0300
committerGitHub <noreply@github.com>2018-10-12 18:29:50 +0300
commita98fa7ff54a0dc7b926deec99b69d5a0a0864a94 (patch)
treeb35d3df1b0ad12324f4094af98a576c6c933571e /test/core
parent24bbbfc9bdbdc0666a53cd4a60a8b57551e9f0ca (diff)
parentb16c0d51d65249f0fdea86cd12cd64f6f0643b7e (diff)
Merge branch 'master' into fix-rprompt-icons-cut-off
Diffstat (limited to 'test/core')
-rwxr-xr-xtest/core/color_overriding.spec62
-rwxr-xr-xtest/core/joining_segments.spec187
-rwxr-xr-xtest/core/prompt.spec104
-rwxr-xr-xtest/core/visual_identifier.spec60
4 files changed, 413 insertions, 0 deletions
diff --git a/test/core/color_overriding.spec b/test/core/color_overriding.spec
new file mode 100755
index 00000000..f2c3d891
--- /dev/null
+++ b/test/core/color_overriding.spec
@@ -0,0 +1,62 @@
+#!/usr/bin/env zsh
+#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
+
+# Required for shunit2 to run correctly
+setopt shwordsplit
+SHUNIT_PARENT=$0
+
+function setUp() {
+ export TERM="xterm-256color"
+ # Load Powerlevel9k
+ source powerlevel9k.zsh-theme
+}
+
+function testDynamicColoringOfSegmentsWork() {
+ local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
+ local POWERLEVEL9K_DATE_ICON="date-icon"
+ local POWERLEVEL9K_DATE_BACKGROUND='red'
+
+ assertEquals "%K{001} %F{000}date-icon %f%F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)"
+}
+
+function testDynamicColoringOfVisualIdentifiersWork() {
+ local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
+ local POWERLEVEL9K_DATE_ICON="date-icon"
+ local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green'
+
+ assertEquals "%K{007} %F{002}date-icon %f%F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
+ local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
+ local POWERLEVEL9K_DATE_ICON="date-icon"
+ local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green'
+ local POWERLEVEL9K_DATE_FOREGROUND='red'
+ local POWERLEVEL9K_DATE_BACKGROUND='yellow'
+
+ assertEquals "%K{003} %F{002}date-icon %f%F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)"
+}
+
+function testColorOverridingOfStatefulSegment() {
+ local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(host)
+ local POWERLEVEL9K_SSH_ICON="ssh-icon"
+ local POWERLEVEL9K_HOST_REMOTE_BACKGROUND='red'
+ local POWERLEVEL9K_HOST_REMOTE_FOREGROUND='green'
+ # Provoke state
+ local SSH_CLIENT="x"
+
+ assertEquals "%K{001} %F{002}ssh-icon %f%F{002}%m %k%F{001}%f " "$(build_left_prompt)"
+}
+
+function testColorOverridingOfCustomSegment() {
+ local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
+ local POWERLEVEL9K_CUSTOM_WORLD='echo world'
+ local POWERLEVEL9K_CUSTOM_WORLD_ICON='CW'
+ local POWERLEVEL9K_CUSTOM_WORLD_VISUAL_IDENTIFIER_COLOR='green'
+ local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND='red'
+ local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND='red'
+
+ assertEquals "%K{001} %F{002}CW %f%F{001}world %k%F{001}%f " "$(build_left_prompt)"
+}
+
+source shunit2/shunit2 \ No newline at end of file
diff --git a/test/core/joining_segments.spec b/test/core/joining_segments.spec
new file mode 100755
index 00000000..18213a52
--- /dev/null
+++ b/test/core/joining_segments.spec
@@ -0,0 +1,187 @@
+#!/usr/bin/env zsh
+#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
+
+# Required for shunit2 to run correctly
+setopt shwordsplit
+SHUNIT_PARENT=$0
+
+function setUp() {
+ export TERM="xterm-256color"
+ # Load Powerlevel9k
+ source powerlevel9k.zsh-theme
+}
+
+function testLeftNormalSegmentsShouldNotBeJoined() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3 custom_world4_joined custom_world5 custom_world6)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+ local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world2 %K{007}%F{000} %F{000}world4 %K{007}%F{000} %F{000}world6 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftJoinedSegments() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000}%F{000}world2 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftTransitiveJoinedSegments() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000}%F{000}world2 %K{007}%F{000}%F{000}world3 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftTransitiveJoiningWithConditionalJoinedSegment() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined custom_world4_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000}%F{000}world2 %K{007}%F{000}%F{000}world4 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftPromotingSegmentWithConditionalPredecessor() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world3 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftPromotingSegmentWithJoinedConditionalPredecessor() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world4 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftPromotingSegmentWithDeepJoinedConditionalPredecessor() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined custom_world5_joined custom_world6_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+ local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
+
+ assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world4 %K{007}%F{000}%F{000}world6 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testLeftJoiningBuiltinSegmentWorks() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version php_version_joined)
+ alias php="echo PHP 1.2.3"
+
+ assertEquals "%K{013} %F{255}PHP 1.2.3 %K{013}%F{255}%F{255}PHP 1.2.3 %k%F{013}%f " "$(build_left_prompt)"
+
+ unalias php
+}
+
+function testRightNormalSegmentsShouldNotBeJoined() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3 custom_world4 custom_world5_joined custom_world6)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+ local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world2 %f%F{000}%f%K{007}%F{000} world4 %f%F{000}%f%K{007}%F{000} world6%E" "$(build_right_prompt)"
+}
+
+function testRightJoinedSegments() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%K{007}%F{000}world2%E" "$(build_right_prompt)"
+}
+
+function testRightTransitiveJoinedSegments() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%K{007}%F{000}world2 %f%K{007}%F{000}world3%E" "$(build_right_prompt)"
+}
+
+function testRightTransitiveJoiningWithConditionalJoinedSegment() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined custom_world4_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%K{007}%F{000}world2 %f%K{007}%F{000}world4%E" "$(build_right_prompt)"
+}
+
+function testRightPromotingSegmentWithConditionalPredecessor() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world3%E" "$(build_right_prompt)"
+}
+
+function testRightPromotingSegmentWithJoinedConditionalPredecessor() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world4%E" "$(build_right_prompt)"
+}
+
+function testRightPromotingSegmentWithDeepJoinedConditionalPredecessor() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined custom_world5_joined custom_world6_joined)
+ local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
+ local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
+ local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
+ local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world4 %f%K{007}%F{000}world6%E" "$(build_right_prompt)"
+}
+
+function testRightJoiningBuiltinSegmentWorks() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(php_version php_version_joined)
+ alias php="echo PHP 1.2.3"
+
+ assertEquals "%F{013}%f%K{013}%F{255} PHP 1.2.3 %f%K{013}%F{255}PHP 1.2.3%E" "$(build_right_prompt)"
+
+ unalias php
+}
+source shunit2/shunit2 \ No newline at end of file
diff --git a/test/core/prompt.spec b/test/core/prompt.spec
new file mode 100755
index 00000000..47d3ac7b
--- /dev/null
+++ b/test/core/prompt.spec
@@ -0,0 +1,104 @@
+#!/usr/bin/env zsh
+#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
+
+# Required for shunit2 to run correctly
+setopt shwordsplit
+SHUNIT_PARENT=$0
+
+function setUp() {
+ export TERM="xterm-256color"
+ # Load Powerlevel9k
+ source powerlevel9k.zsh-theme
+}
+
+function testSegmentOnRightSide() {
+ # Reset RPROMPT, so a running P9K does not interfere with the test
+ local RPROMPT=
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_CUSTOM_WORLD2='echo world2'
+
+ powerlevel9k_prepare_prompts
+
+ local reset_attributes=$'\e[00m'
+ assertEquals "%f%b%k%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world2%E%{${reset_attributes}%}" "${(e)RPROMPT}"
+}
+
+function testDisablingRightPrompt() {
+ # Reset RPROMPT, so a running P9K does not interfere with the test
+ local RPROMPT=
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_CUSTOM_WORLD2='echo world2'
+ local POWERLEVEL9K_DISABLE_RPROMPT=true
+
+ powerlevel9k_prepare_prompts
+
+ assertEquals "" "${(e)RPROMPT}"
+}
+
+function testLeftMultilinePrompt() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
+
+ powerlevel9k_prepare_prompts
+
+ local nl=$'\n'
+ assertEquals "╭─%f%b%k%K{007} %F{000}world1 %k%F{007}%f ${nl}╰─ " "${(e)PROMPT}"
+}
+
+function testRightPromptOnSameLine() {
+ # Reset RPROMPT, so a running P9K does not interfere with the test
+ local RPROMPT=
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+
+ local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
+ local POWERLEVEL9K_RPROMPT_ON_NEWLINE=false # We want the RPROMPT on the same line as our left prompt
+
+ # Skip test, as this cannot be tested properly.
+ # The "go one line up" instruction does not get
+ # printed as real characters in RPROMPT.
+ # On command line the assert statement produces
+ # a visually identical output as we expect, but
+ # it fails anyway. :(
+ startSkipping
+
+ powerlevel9k_prepare_prompts
+ assertEquals "%{\e[1A%}%F{007}%f%K{007}%F{000} world1 %f%{\e[1B%}" "${(e)RPROMPT}"
+}
+
+function testPrefixingFirstLineOnLeftPrompt() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+
+ local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
+ local POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='XXX'
+
+ powerlevel9k_prepare_prompts
+
+ local nl=$'\n'
+ assertEquals "XXX%f%b%k%K{007} %F{000}world1 %k%F{007}%f ${nl}╰─ " "${(e)PROMPT}"
+}
+
+function testPrefixingSecondLineOnLeftPrompt() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+
+ local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
+ local POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='XXX'
+
+ powerlevel9k_prepare_prompts
+
+ local nl=$'\n'
+ assertEquals "╭─%f%b%k%K{007} %F{000}world1 %k%F{007}%f ${nl}XXX" "${(e)PROMPT}"
+}
+
+source shunit2/shunit2
diff --git a/test/core/visual_identifier.spec b/test/core/visual_identifier.spec
new file mode 100755
index 00000000..c6c6bef5
--- /dev/null
+++ b/test/core/visual_identifier.spec
@@ -0,0 +1,60 @@
+#!/usr/bin/env zsh
+#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
+
+# Required for shunit2 to run correctly
+setopt shwordsplit
+SHUNIT_PARENT=$0
+
+function setUp() {
+ export TERM="xterm-256color"
+ # Load Powerlevel9k
+ source powerlevel9k.zsh-theme
+ source functions/*
+}
+
+function testOverwritingIconsWork() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
+
+ assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
+
+ assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
+ local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
+ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
+
+ assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%f%E" "$(build_right_prompt)"
+}
+
+function testVisualIdentifierPrintsNothingIfNotAvailable() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+
+ assertEquals "%K{007} %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+function testVisualIdentifierIsPrintedInNumericalColorCode() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
+ local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
+ local POWERLEVEL9K_CUSTOM_WORLD1_ICON="xxx"
+ local POWERLEVEL9K_CUSTOM_WORLD1_VISUAL_IDENTIFIER_COLOR="purple3"
+
+ assertEquals "%K{007} %F{056}xxx %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
+}
+
+source shunit2/shunit2 \ No newline at end of file