aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin--handle-fetch-callback.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-wttrin--handle-fetch-callback.el')
-rw-r--r--tests/test-wttrin--handle-fetch-callback.el37
1 files changed, 24 insertions, 13 deletions
diff --git a/tests/test-wttrin--handle-fetch-callback.el b/tests/test-wttrin--handle-fetch-callback.el
index 203a232..ccd455e 100644
--- a/tests/test-wttrin--handle-fetch-callback.el
+++ b/tests/test-wttrin--handle-fetch-callback.el
@@ -10,10 +10,21 @@
(require 'ert)
(require 'wttrin)
+(require 'testutil-wttrin)
+
+;;; Setup and Teardown
+
+(defun test-wttrin--handle-fetch-callback-setup ()
+ "Setup for handle-fetch-callback tests."
+ (testutil-wttrin-setup))
+
+(defun test-wttrin--handle-fetch-callback-teardown ()
+ "Teardown for handle-fetch-callback tests."
+ (testutil-wttrin-teardown))
;;; Normal Cases
-(ert-deftest test-wttrin--handle-fetch-callback-normal-successful-response ()
+(ert-deftest test-wttrin--handle-fetch-callback-normal-successful-response-calls-callback-with-data ()
"Test handling successful response with callback invocation."
(let ((callback-called nil)
(callback-data nil))
@@ -29,7 +40,7 @@
(should callback-called)
(should (string= "Weather: ☀️ Sunny" callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-normal-empty-response ()
+(ert-deftest test-wttrin--handle-fetch-callback-normal-empty-response-calls-callback-with-empty ()
"Test handling empty but successful response."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -44,7 +55,7 @@
(should callback-called)
(should (string= "" callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-normal-large-response ()
+(ert-deftest test-wttrin--handle-fetch-callback-normal-large-response-calls-callback-with-full-data ()
"Test handling large response data."
(let ((callback-called nil)
(callback-data nil)
@@ -63,7 +74,7 @@
;;; Boundary Cases
-(ert-deftest test-wttrin--handle-fetch-callback-boundary-nil-status ()
+(ert-deftest test-wttrin--handle-fetch-callback-boundary-nil-status-calls-callback ()
"Test handling nil status (successful response)."
(let ((callback-called nil))
(cl-letf (((symbol-function 'wttrin--extract-response-body)
@@ -75,7 +86,7 @@
(should callback-called))))
-(ert-deftest test-wttrin--handle-fetch-callback-boundary-empty-status-plist ()
+(ert-deftest test-wttrin--handle-fetch-callback-boundary-empty-status-plist-calls-callback ()
"Test handling empty status plist."
(let ((callback-called nil)
(callback-data nil))
@@ -90,7 +101,7 @@
(should callback-called)
(should (string= "data" callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-boundary-status-with-other-keys ()
+(ert-deftest test-wttrin--handle-fetch-callback-boundary-status-with-other-keys-calls-callback ()
"Test handling status with various keys but no error."
(let ((callback-called nil))
(cl-letf (((symbol-function 'wttrin--extract-response-body)
@@ -104,7 +115,7 @@
;;; Error Cases
-(ert-deftest test-wttrin--handle-fetch-callback-error-network-error ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-network-error-calls-callback-with-nil ()
"Test handling network error in status."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -117,7 +128,7 @@
(should callback-called)
(should (null callback-data))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-http-404 ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-http-404-calls-callback-with-nil ()
"Test handling HTTP error status."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -130,7 +141,7 @@
(should callback-called)
(should (null callback-data))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-timeout ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-timeout-calls-callback-with-nil ()
"Test handling timeout error."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -143,7 +154,7 @@
(should callback-called)
(should (null callback-data))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-callback-throws ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-callback-throws-does-not-propagate ()
"Test handling errors thrown by user callback."
(let ((callback-called nil)
(error-caught nil))
@@ -163,7 +174,7 @@
;; Error should be caught and handled, not propagated
(should-not error-caught))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-extract-body-throws ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-extract-body-throws-propagates-error ()
"Test that errors during body extraction are not caught and propagate."
(let ((callback-called nil)
(error-caught nil))
@@ -181,7 +192,7 @@
(should-not callback-called)
(should error-caught))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-nil-data-from-extract ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-nil-data-from-extract-calls-callback-with-nil ()
"Test handling nil data returned from extraction."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -196,7 +207,7 @@
(should callback-called)
(should (null callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-multiple-error-keys ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-multiple-error-keys-calls-callback-with-nil ()
"Test handling status with multiple error indicators."
(let ((callback-called nil)
(callback-data 'not-nil))