aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2016-02-26 17:21:33 +0300
committerDominik Ritter <dritter03@googlemail.com>2016-02-26 17:53:09 +0300
commit359109978964d226e9b0697c2e30e074ae5c8548 (patch)
tree362c9139a2b25fee641ba8cff2ed94355d579390
parent9ac79bd3aa49f037d3fc19bdf859b7ae1b05b762 (diff)
Add tests for dynamic color overriding of vcs segment
-rw-r--r--.travis.yml1
-rwxr-xr-xtest/segments/vcs.spec77
2 files changed, 78 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 71aff690..4f2c7a39 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,4 +24,5 @@ script:
- test/segments/dir.spec
- test/segments/rust_version.spec
- test/segments/go_version.spec
+ - test/segments/vcs.spec
diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec
new file mode 100755
index 00000000..862067b7
--- /dev/null
+++ b/test/segments/vcs.spec
@@ -0,0 +1,77 @@
+#!/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 testColorOverridingForCleanStateWorks() {
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
+ POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
+ POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
+
+ FOLDER=/tmp/powerlevel9k-test/vcs-test
+ mkdir -p $FOLDER
+ cd $FOLDER
+ git init 1>/dev/null
+
+ assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)"
+
+ cd -
+ rm -fr /tmp/powerlevel9k-test
+
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_VCS_CLEAN_FOREGROUND
+ unset POWERLEVEL9K_VCS_CLEAN_BACKGROUND
+}
+
+function testColorOverridingForModifiedStateWorks() {
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
+ POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
+ POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
+
+ FOLDER=/tmp/powerlevel9k-test/vcs-test
+ mkdir -p $FOLDER
+ cd $FOLDER
+ git init 1>/dev/null
+ touch testfile
+ git add testfile
+
+ assertEquals "%K{yellow} %F{red} master ✚ %k%F{yellow}%f " "$(build_left_prompt)"
+
+ cd -
+ rm -fr /tmp/powerlevel9k-test
+
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_VCS_MODIFIED_FOREGROUND
+ unset POWERLEVEL9K_VCS_MODIFIED_BACKGROUND
+}
+
+function testColorOverridingForUntrackedStateWorks() {
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
+ POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan'
+ POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
+
+ FOLDER=/tmp/powerlevel9k-test/vcs-test
+ mkdir -p $FOLDER
+ cd $FOLDER
+ git init 1>/dev/null
+ touch testfile
+
+ assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)"
+
+ cd -
+ rm -fr /tmp/powerlevel9k-test
+
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND
+ unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
+}
+
+source shunit2/source/2.1/src/shunit2