diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2018-07-18 23:21:27 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2018-07-18 23:21:27 +0300 |
commit | 85cc62b72b3ab10fffe03b1446f1403e7c42b21d (patch) | |
tree | 0712fcf2c133b673341571ecaf220e70570daef8 /test/segments | |
parent | 2efbd7e1880f62801db2d3739e3d33b2dfc1b154 (diff) |
Add tests for node_version segment
Diffstat (limited to 'test/segments')
-rwxr-xr-x | test/segments/node_version.spec | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/segments/node_version.spec b/test/segments/node_version.spec new file mode 100755 index 00000000..2fe3594e --- /dev/null +++ b/test/segments/node_version.spec @@ -0,0 +1,36 @@ +#!/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 testNodeVersionSegmentPrintsNothingWithoutNode() { + local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world) + local POWERLEVEL9K_CUSTOM_WORLD='echo world' + alias node="nonode 2>/dev/null" + + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_CUSTOM_WORLD + unalias node +} + +function testNodeVersionSegmentWorks() { + local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version) + node() { + echo "v1.2.3" + } + + assertEquals "%K{green} %F{white%}⬢ %f%F{white}1.2.3 %k%F{green}%f " "$(build_left_prompt)" + + unfunction node +} + +source shunit2/source/2.1/src/shunit2
\ No newline at end of file |