mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-07-03 14:13:43 +00:00
port another test
This commit is contained in:
parent
58813cc86c
commit
36b0251e5b
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
NVM_SRC_DIR="${BATS_TEST_DIRNAME}/../.."
|
NVM_SRC_DIR="${BATS_TEST_DIRNAME}/../.."
|
||||||
load "${NVM_SRC_DIR}/nvm.sh"
|
load "${NVM_SRC_DIR}/nvm.sh"
|
||||||
|
|
||||||
@ -20,13 +22,25 @@ teardown() {
|
|||||||
|
|
||||||
@test "'nvm' command defined in environment" {
|
@test "'nvm' command defined in environment" {
|
||||||
run nvm
|
run nvm
|
||||||
[ "$status" -eq 0 ]
|
assert_equal "$status" "0" "nvm command defined"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Running 'nvm alias' should create a file in the alias directory." {
|
@test "Running 'nvm alias' should create a file in the alias directory." {
|
||||||
run nvm alias test v0.1.2
|
run nvm alias test v0.1.2
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
result=$(cat "alias/test")
|
result=$(cat "alias/test")
|
||||||
[ "$result" = "v0.1.2" ]
|
assert_equal "$result" "v0.1.2" "expected new alias"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test './Listing versions/Running "nvm ls 0.0.2" should display only version 0.0.2.' {
|
||||||
|
|
||||||
|
mkdir -p v0.0.2
|
||||||
|
mkdir -p v0.0.20
|
||||||
|
|
||||||
|
run nvm ls 0.0.2
|
||||||
|
assert_match ${lines[0]} "v0.0.2" "nvm ls 0.0.2 must contain v0.0.2"
|
||||||
|
|
||||||
|
run nvm ls 0.0.2
|
||||||
|
assert_nomatch "$output" "v0.0.20" "nvm ls 0.0.2 must NOT contain v0.0.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,24 @@ assert_equal() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_match() {
|
||||||
|
if [[ ! "$1" =~ $2 ]]; then
|
||||||
|
{ [ -z "$3" ] || echo "$3"
|
||||||
|
echo "expected: $1"
|
||||||
|
echo "to match: $2"
|
||||||
|
} | flunk
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_nomatch() {
|
||||||
|
if [[ "$1" =~ $2 ]]; then
|
||||||
|
{ [ -z "$3" ] || echo "$3"
|
||||||
|
echo "expected : $1"
|
||||||
|
echo "to not match: $2"
|
||||||
|
} | flunk
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
assert_unequal() {
|
assert_unequal() {
|
||||||
if [ "$1" = "$2" ]; then
|
if [ "$1" = "$2" ]; then
|
||||||
{ [ -z "$3" ] || echo "$3"
|
{ [ -z "$3" ] || echo "$3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user