File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -156,3 +156,26 @@ function test_failure() {
156156}
157157```
158158:::
159+
160+ ## assert_not_called
161+ > ` assert_not_called "spy" `
162+
163+ Reports an error if ` spy ` has been executed at least once.
164+
165+ ::: code-group
166+ ``` bash [Example]
167+ function test_success() {
168+ spy ps
169+
170+ assert_not_called ps
171+ }
172+
173+ function test_failure() {
174+ spy ps
175+
176+ ps
177+
178+ assert_not_called ps
179+ }
180+ ```
181+ :::
Original file line number Diff line number Diff line change @@ -141,3 +141,9 @@ function assert_have_been_called_times() {
141141
142142 state::add_assertions_passed
143143}
144+
145+ function assert_not_called() {
146+ local command=$1
147+ local label=" ${2:- $(helper:: normalize_test_function_name " ${FUNCNAME[1]} " )} "
148+ assert_have_been_called_times 0 " $command " " $label "
149+ }
Original file line number Diff line number Diff line change @@ -147,3 +147,21 @@ function test_spy_called_with_different_arguments() {
147147 assert_have_been_called_with " first_a first_b" ps 1
148148 assert_have_been_called_with " second" ps 2
149149}
150+
151+ function test_spy_successful_not_called() {
152+ spy ps
153+
154+ assert_not_called ps
155+ }
156+
157+ function test_spy_unsuccessful_not_called() {
158+ spy ps
159+
160+ ps
161+
162+ assert_same \
163+ " $( console_results::print_failed_test " Spy unsuccessful not called" " ps" \
164+ " to has been called" " 0 times" \
165+ " actual" " 1 times" ) " \
166+ " $( assert_not_called ps) "
167+ }
You can’t perform that action at this time.
0 commit comments