[Tests] Ensure color codes are stripped in alias tests.

This commit is contained in:
Jordan Harband
2016-04-27 17:05:33 -07:00
parent 9106cc25a4
commit 379d079c30
11 changed files with 111 additions and 97 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/sh
. ../../../nvm.sh
. ../../common.sh
die () { echo $@ ; exit 1; }
@@ -10,12 +11,14 @@ if [ -n "$ZSH_VERSION" ]; then
setopt noclobber
fi
nvm alias test-stable-1 0.0.2
nvm alias test-stable-1 0.0.2 || die '`nvm alias test-stable-1 0.0.2` failed'
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.2 (-> v0.0.2)" \
|| die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2"
OUTPUT="$(nvm alias test-stable-1 | strip_colors)"
EXPECTED_OUTPUT='test-stable-1 -> 0.0.2 (-> v0.0.2)'
echo "$OUTPUT" | \grep -F "$EXPECTED_OUTPUT" || die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2: got '$OUTPUT'"
nvm alias test-stable-1 0.0.1
nvm alias test-stable-1 0.0.1 || die '`nvm alias test-stable-1 0.0.1` failed'
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.1 (-> v0.0.1)" \
|| die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1"
OUTPUT="$(nvm alias test-stable-1 | strip_colors)"
EXPECTED_OUTPUT='test-stable-1 -> 0.0.1 (-> v0.0.1)'
echo "$OUTPUT" | \grep -F "$EXPECTED_OUTPUT" || die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1: got '$OUTPUT'"