Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
tighten node_version test code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBaker97 committed Mar 18, 2019
1 parent db3bfbf commit 21b9a5a
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions segments/node_version/node_version.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ SHUNIT_PARENT=$0
function oneTimeSetUp() {
export TERM="xterm-256color"

OLDPATH="${PATH}"
PATH="${NODE_VERSION_TEST_FOLDER}:${PATH}"

OLD_DIR="${PWD}"

TEST_BASE_FOLDER="/tmp/powerlevel9k-test"
NODE_VERSION_TEST_FOLDER="${TEST_BASE_FOLDER}/node_version-test"

OLDPATH="${PATH}"
PATH="${NODE_VERSION_TEST_FOLDER}:${PATH}"

P9K_CUSTOM_WORLD='echo world'

node() {
echo "v1.2.3"
Expand Down Expand Up @@ -46,14 +48,11 @@ function oneTimeTearDown() {
}

function testNodeVersionSegmentWorks() {
P9K_NODE_VERSION_PROJECT_ONLY=false

assertEquals "%K{002} %F{015}⬢ %F{015}1.2.3 %k%F{002}%f " "$(__p9k_build_left_prompt)"
}

function testNodeVersionSegmentPrintsNothingWithoutNode() {
P9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
local P9K_CUSTOM_WORLD='echo world'
P9K_LEFT_PROMPT_ELEMENTS+=(custom_world)

alias node="nonode 2>/dev/null"

Expand All @@ -63,8 +62,7 @@ function testNodeVersionSegmentPrintsNothingWithoutNode() {
}

function testNodeVersionSegmentProjectOnlyPrintsNothingOutsideProjectDirectory() {
P9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
local P9K_CUSTOM_WORLD='echo world'
P9K_LEFT_PROMPT_ELEMENTS+=(custom_world)

P9K_NODE_VERSION_PROJECT_ONLY=true

Expand All @@ -77,8 +75,6 @@ function testNodeVersionSegmentProjectOnlyWorksInsideProjectDirectory() {
touch ./package.json

assertEquals "%K{002} %F{015}⬢ %F{015}1.2.3 %k%F{002}%f " "$(__p9k_build_left_prompt)"

rm ./package.json
}

function testNodeVersionSegmentProjectOnlyWorksInsideProjectChildDirectory() {
Expand All @@ -89,9 +85,6 @@ function testNodeVersionSegmentProjectOnlyWorksInsideProjectChildDirectory() {
cd test-child

assertEquals "%K{002} %F{015}⬢ %F{015}1.2.3 %k%F{002}%f " "$(__p9k_build_left_prompt)"

cd ..
rm ./package.json
}

source shunit2/shunit2

0 comments on commit 21b9a5a

Please sign in to comment.