diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2018-07-19 08:40:58 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2018-07-19 08:40:58 +0300 |
commit | d13410d38c12e23f0a61c63625d5ad7889f86730 (patch) | |
tree | c6cdadeb5ad2f0b2b2654647b23b94f8077e6540 /test/segments | |
parent | aa5e9ccc3b089291c8653e5259725a61e4c749ba (diff) |
Fix tests for nvm segment
Diffstat (limited to 'test/segments')
-rwxr-xr-x | test/segments/nvm.spec | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/test/segments/nvm.spec b/test/segments/nvm.spec index fe40b067..8f3b3c26 100755 --- a/test/segments/nvm.spec +++ b/test/segments/nvm.spec @@ -14,11 +14,15 @@ function setUp() { ### Test specific # Create default folder and git init it. FOLDER=/tmp/powerlevel9k-test/nvm-test - mkdir -p "${FOLDER}" + mkdir -p "${FOLDER}/bin" + OLD_PATH=$PATH + PATH=${FOLDER}/bin:$PATH cd $FOLDER } function tearDown() { + # Restore old path + PATH="${OLD_PATH}" # Go back to powerlevel9k folder cd "${P9K_HOME}" # Remove eventually created test-specific folder @@ -30,37 +34,29 @@ function tearDown() { function testNvmSegmentPrintsNothingIfNvmIsNotAvailable() { local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world) local POWERLEVEL9K_CUSTOM_WORLD='echo world' - alias nvm=nonvm assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_CUSTOM_WORLD - unalias nvm } function testNvmSegmentWorksWithoutHavingADefaultAlias() { local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm) - nvm() { echo 'v4.6.0'; } - assertEquals "%K{green} %F{011%}⬢ %f%F{011}4.6.0 %k%F{green}%f " "$(build_left_prompt)" + function nvm_version() { + [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0' + } - unfunction nvm + assertEquals "%K{magenta} %F{black%}⬢ %f%F{black}4.6.0 %k%F{magenta}%f " "$(build_left_prompt)" } function testNvmSegmentPrintsNothingWhenOnDefaultVersion() { local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world) local POWERLEVEL9K_CUSTOM_WORLD='echo world' - nvm() { echo 'v4.6.0'; } - export NVM_DIR="${FOLDER}" - mkdir alias - echo 'v4.6.0' > alias/default + function nvm_version() { + [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v4.6.0' + } assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unfunction nvm - unset POWERLEVEL9K_CUSTOM_WORLD - unset NVM_DIR } source shunit2/source/2.1/src/shunit2
\ No newline at end of file |