Skip to content

Commit

Permalink
[Tests] Fix nvm_ls_current fast test
Browse files Browse the repository at this point in the history
  • Loading branch information
reasonablytall authored and ljharb committed Oct 13, 2020
1 parent e01060f commit e77ed07
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/fast/Unit tests/nvm_ls_current
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ fi

rm -rf "$TEST_DIR"
mkdir "$TEST_DIR"
ln -s "$(command which which)" "$TEST_DIR/which"
# Ensure that the system version of which is used, not node_modules/.bin/which
ln -s "$(PATH=$(echo $PATH | tr ":" "\n" | grep -v "node_modules/.bin" | tr "\n" ":") command which which)" "$TEST_DIR/which"
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
ln -s "$(command which printf)" "$TEST_DIR/printf"

[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'

echo "#!/bin/bash" > "$TEST_DIR/node"
echo "echo 'VERSION FOO!'" > "$TEST_DIR/node"
echo "echo 'VERSION FOO!'" >> "$TEST_DIR/node"
chmod a+x "$TEST_DIR/node"

[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'

alias node='node --harmony'
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'

cleanup

0 comments on commit e77ed07

Please sign in to comment.