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

Commit 21b9a5a

Browse files
committed
tighten node_version test code
1 parent db3bfbf commit 21b9a5a

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

segments/node_version/node_version.spec

+7-14
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ SHUNIT_PARENT=$0
88
function oneTimeSetUp() {
99
export TERM="xterm-256color"
1010

11-
OLDPATH="${PATH}"
12-
PATH="${NODE_VERSION_TEST_FOLDER}:${PATH}"
13-
1411
OLD_DIR="${PWD}"
1512

1613
TEST_BASE_FOLDER="/tmp/powerlevel9k-test"
1714
NODE_VERSION_TEST_FOLDER="${TEST_BASE_FOLDER}/node_version-test"
15+
16+
OLDPATH="${PATH}"
17+
PATH="${NODE_VERSION_TEST_FOLDER}:${PATH}"
18+
19+
P9K_CUSTOM_WORLD='echo world'
1820

1921
node() {
2022
echo "v1.2.3"
@@ -46,14 +48,11 @@ function oneTimeTearDown() {
4648
}
4749

4850
function testNodeVersionSegmentWorks() {
49-
P9K_NODE_VERSION_PROJECT_ONLY=false
50-
5151
assertEquals "%K{002} %F{015}⬢ %F{015}1.2.3 %k%F{002}%f " "$(__p9k_build_left_prompt)"
5252
}
5353

5454
function testNodeVersionSegmentPrintsNothingWithoutNode() {
55-
P9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
56-
local P9K_CUSTOM_WORLD='echo world'
55+
P9K_LEFT_PROMPT_ELEMENTS+=(custom_world)
5756

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

@@ -63,8 +62,7 @@ function testNodeVersionSegmentPrintsNothingWithoutNode() {
6362
}
6463

6564
function testNodeVersionSegmentProjectOnlyPrintsNothingOutsideProjectDirectory() {
66-
P9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
67-
local P9K_CUSTOM_WORLD='echo world'
65+
P9K_LEFT_PROMPT_ELEMENTS+=(custom_world)
6866

6967
P9K_NODE_VERSION_PROJECT_ONLY=true
7068

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

7977
assertEquals "%K{002} %F{015}⬢ %F{015}1.2.3 %k%F{002}%f " "$(__p9k_build_left_prompt)"
80-
81-
rm ./package.json
8278
}
8379

8480
function testNodeVersionSegmentProjectOnlyWorksInsideProjectChildDirectory() {
@@ -89,9 +85,6 @@ function testNodeVersionSegmentProjectOnlyWorksInsideProjectChildDirectory() {
8985
cd test-child
9086

9187
assertEquals "%K{002} %F{015}⬢ %F{015}1.2.3 %k%F{002}%f " "$(__p9k_build_left_prompt)"
92-
93-
cd ..
94-
rm ./package.json
9588
}
9689

9790
source shunit2/shunit2

0 commit comments

Comments
 (0)