summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2018-07-19 09:15:50 +0300
committerDominik Ritter <dritter03@googlemail.com>2018-07-19 09:15:50 +0300
commitcf353f5660c6b11220032264a3e9635a12e5e451 (patch)
tree03f0eaa85aed60ed78fe9ebf70bed647f5652288 /test
parent7a7b4ee13aa69bcc2006cd9b13b67732d05c48be (diff)
Add tests for color overriding
Diffstat (limited to 'test')
-rwxr-xr-xtest/core/color_overriding.spec62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/core/color_overriding.spec b/test/core/color_overriding.spec
new file mode 100755
index 00000000..ead890d7
--- /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{red} %F{black%}date-icon %f%F{black}%D{%d.%m.%y} %k%F{red}%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{white} %F{green%}date-icon %f%F{black}%D{%d.%m.%y} %k%F{white}%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{yellow} %F{green%}date-icon %f%F{red}%D{%d.%m.%y} %k%F{yellow}%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{red} %F{green%}ssh-icon %f%F{green}%m %k%F{red}%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{red} %F{green%}CW %f%F{red}world %k%F{red}%f " "$(build_left_prompt)"
+}
+
+source shunit2/source/2.1/src/shunit2 \ No newline at end of file