mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-10-30 17:25:51 +08:00
Adding unit tests for --silent
This commit is contained in:
@@ -8,10 +8,15 @@ nvm_has_system_node() { return 0; }
|
||||
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
||||
EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
|
||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node"
|
||||
EXPECTED_OUTPUT=""
|
||||
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node or --silent was not silent"
|
||||
|
||||
nvm_has_system_node() { return 1; }
|
||||
nvm_print_npm_version() { return ''; }
|
||||
EXPECTED_OUTPUT="System version of node not found."
|
||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found"
|
||||
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
||||
EXPECTED_OUTPUT=""
|
||||
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found or --silent was not silent"
|
||||
nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user