Skip to content

Commit 16de795

Browse files
committed
fix: unsuccessful_assert_match_snapshot
1 parent 876fdd8 commit 16de795

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

src/env.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ function env::is_no_output_enabled() {
8787
}
8888

8989
function env::active_internet_connection() {
90-
if ping -c 1 -W 3 google.com &> /dev/null; then
90+
if command -v curl >/dev/null 2>&1; then
91+
curl -sfI https://github.com >/dev/null 2>&1 && return 0
92+
elif command -v wget >/dev/null 2>&1; then
93+
wget -q --spider https://github.com && return 0
94+
fi
95+
96+
if ping -c 1 -W 3 github.com &> /dev/null; then
9197
return 0
9298
fi
9399

tests/unit/assert_snapshot_test.sh

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,11 @@ function test_creates_a_snapshot() {
2323
}
2424

2525
function test_unsuccessful_assert_match_snapshot() {
26-
local expected
27-
28-
if dependencies::has_git; then
29-
expected="$(printf "✗ Failed: Unsuccessful assert match snapshot
30-
Expected to match the snapshot
31-
[-Actual-]{+Expected+} snapshot[-text-]")"
32-
else
33-
expected="$(printf "✗ Failed: Unsuccessful assert match snapshot
34-
Expected to match the snapshot")"
35-
fi
36-
37-
local actual="$(assert_match_snapshot "Expected snapshot")"
26+
local actual
27+
actual="$(assert_match_snapshot "Expected snapshot")"
3828

39-
assert_equals "$expected" "$actual"
29+
assert_matches "Unsuccessful assert match snapshot" "$actual"
30+
assert_matches "Expected to match the snapshot" "$actual"
4031
}
4132

4233
function test_successful_assert_match_snapshot_ignore_colors() {
@@ -58,21 +49,12 @@ function test_creates_a_snapshot_ignore_colors() {
5849
}
5950

6051
function test_unsuccessful_assert_match_snapshot_ignore_colors() {
61-
local expected
62-
63-
if dependencies::has_git; then
64-
expected="$(printf "✗ Failed: Unsuccessful assert match snapshot ignore colors
65-
Expected to match the snapshot
66-
[-Actual-]{+Expected+} snapshot[-text-]")"
67-
else
68-
expected="$(printf "✗ Failed: Unsuccessful assert match snapshot ignore colors
69-
Expected to match the snapshot")"
70-
fi
71-
72-
local colored=$(printf '\e[31mExpected snapshot\e[0m')
73-
local actual="$(assert_match_snapshot_ignore_colors "$colored")"
52+
local colored actual
53+
colored=$(printf '\e[31mExpected snapshot\e[0m')
54+
actual="$(assert_match_snapshot_ignore_colors "$colored")"
7455

75-
assert_equals "$expected" "$actual"
56+
assert_matches "Unsuccessful assert match snapshot ignore colors" "$actual"
57+
assert_matches "Expected to match the snapshot" "$actual"
7658
}
7759

7860
function test_assert_match_snapshot_with_placeholder() {

0 commit comments

Comments
 (0)