@@ -40,3 +40,47 @@ function test_unsuccessful_assert_match_snapshot() {
4040
4141 assert_equals " $expected " " $actual "
4242}
43+
44+ function test_successful_assert_match_snapshot_ignore_colors() {
45+ local colored
46+ colored=$( printf ' \e[31mHello\e[0m World!' )
47+ assert_empty " $( assert_match_snapshot_ignore_colors " $colored " ) "
48+ }
49+
50+ function test_creates_a_snapshot_ignore_colors() {
51+ local snapshot_file_path=tests/unit/snapshots/assert_snapshot_test_sh.test_creates_a_snapshot_ignore_colors.snapshot
52+ local expected=$(( _ASSERTIONS_SNAPSHOT + 1 ))
53+
54+ assert_file_not_exists $snapshot_file_path
55+
56+ local colored
57+ colored=$( printf ' \e[32mExpected\e[0m snapshot' )
58+
59+ assert_match_snapshot_ignore_colors " $colored "
60+
61+ assert_same " $expected " " $_ASSERTIONS_SNAPSHOT "
62+ assert_file_exists $snapshot_file_path
63+ assert_same " Expected snapshot" " $( cat $snapshot_file_path ) "
64+
65+ rm $snapshot_file_path
66+ }
67+
68+ function test_unsuccessful_assert_match_snapshot_ignore_colors() {
69+ local expected
70+
71+ if dependencies::has_git; then
72+ expected=" $( printf " ✗ Failed: Unsuccessful assert match snapshot ignore colors
73+ Expected to match the snapshot
74+ [-Actual-]{+Expected+} snapshot[-text-]" ) "
75+ else
76+ expected=" $( printf " ✗ Failed: Unsuccessful assert match snapshot ignore colors
77+ Expected to match the snapshot" ) "
78+ fi
79+
80+ local actual
81+ local colored
82+ colored=$( printf ' \e[31mExpected snapshot\e[0m' )
83+ actual=" $( assert_match_snapshot_ignore_colors " $colored " ) "
84+
85+ assert_equals " $expected " " $actual "
86+ }
0 commit comments