aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin--process-weather-content.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-wttrin--process-weather-content.el')
-rw-r--r--tests/test-wttrin--process-weather-content.el35
1 files changed, 23 insertions, 12 deletions
diff --git a/tests/test-wttrin--process-weather-content.el b/tests/test-wttrin--process-weather-content.el
index a372f4c..eb845af 100644
--- a/tests/test-wttrin--process-weather-content.el
+++ b/tests/test-wttrin--process-weather-content.el
@@ -11,27 +11,38 @@
(require 'ert)
(require 'wttrin)
(require 'xterm-color)
+(require 'testutil-wttrin)
+
+;;; Setup and Teardown
+
+(defun test-wttrin--process-weather-content-setup ()
+ "Setup for process-weather-content tests."
+ (testutil-wttrin-setup))
+
+(defun test-wttrin--process-weather-content-teardown ()
+ "Teardown for process-weather-content tests."
+ (testutil-wttrin-teardown))
;;; Normal Cases
-(ert-deftest test-wttrin--process-weather-content-normal-plain-text ()
+(ert-deftest test-wttrin--process-weather-content-normal-plain-text-returns-unchanged ()
"Test processing plain text without ANSI codes or Location lines."
(let ((input "Weather: Sunny\nTemperature: 20°C"))
(should (string= input (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-normal-removes-location-line ()
+(ert-deftest test-wttrin--process-weather-content-normal-location-line-is-removed ()
"Test that Location line with coordinates is removed."
(let ((input "Weather: Sunny\n Location: Paris [48.8566, 2.3522]\nTemperature: 20°C")
(expected "Weather: Sunny\nTemperature: 20°C"))
(should (string= expected (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-normal-multiple-location-lines ()
+(ert-deftest test-wttrin--process-weather-content-normal-multiple-location-lines-all-removed ()
"Test that multiple Location lines are all removed."
(let ((input "Location: Paris [48.8566, 2.3522]\nWeather: Sunny\n Location: Test [0, 0]\nTemp: 20°C")
(expected "Weather: Sunny\nTemp: 20°C"))
(should (string= expected (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-normal-with-ansi-codes ()
+(ert-deftest test-wttrin--process-weather-content-normal-ansi-codes-are-filtered ()
"Test that ANSI color codes are filtered by xterm-color-filter."
;; xterm-color-filter should process ANSI codes
;; We'll test that the function calls xterm-color-filter by checking
@@ -44,50 +55,50 @@
;;; Boundary Cases
-(ert-deftest test-wttrin--process-weather-content-boundary-empty-string ()
+(ert-deftest test-wttrin--process-weather-content-boundary-empty-string-returns-empty ()
"Test processing empty string."
(should (string= "" (wttrin--process-weather-content ""))))
-(ert-deftest test-wttrin--process-weather-content-boundary-only-location-line ()
+(ert-deftest test-wttrin--process-weather-content-boundary-only-location-line-returns-empty ()
"Test processing string with only a Location line removes it."
(let ((input " Location: Test [0, 0]\n")
(expected ""))
;; Input must have newline for delete-region to work correctly
(should (string= expected (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-boundary-location-without-brackets ()
+(ert-deftest test-wttrin--process-weather-content-boundary-location-without-brackets-preserved ()
"Test that Location line without brackets is not removed (doesn't match pattern)."
(let ((input "Location: Paris\nWeather: Sunny"))
;; Pattern requires [coordinates], so this line should remain
(should (string-match-p "Location: Paris" (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-boundary-location-case-insensitive ()
+(ert-deftest test-wttrin--process-weather-content-boundary-location-case-insensitive-removed ()
"Test that 'location' (lowercase) IS removed due to case-insensitive regex."
(let ((input "location: test [0, 0]\nWeather: Sunny"))
;; re-search-forward uses case-fold-search (defaults to t)
;; so lowercase 'location' matches 'Location' pattern
(should-not (string-match-p "location:" (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-boundary-whitespace-variations ()
+(ert-deftest test-wttrin--process-weather-content-boundary-whitespace-variations-removed ()
"Test Location line with various whitespace patterns."
(let ((input " Location: Test [1, 2] \nWeather: Sunny")
(expected "Weather: Sunny"))
(should (string= expected (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-boundary-preserves-non-location-brackets ()
+(ert-deftest test-wttrin--process-weather-content-boundary-non-location-brackets-preserved ()
"Test that lines with brackets but not Location pattern are preserved."
(let ((input "Weather: [Sunny] 20°C\nWind: [Strong]"))
(should (string= input (wttrin--process-weather-content input)))))
;;; Error Cases
-(ert-deftest test-wttrin--process-weather-content-error-handles-malformed-ansi ()
+(ert-deftest test-wttrin--process-weather-content-error-malformed-ansi-returns-string ()
"Test that function handles malformed ANSI codes gracefully."
;; xterm-color-filter should handle this, but we verify no errors occur
(let ((input "\x1b[9999mInvalid ANSI\nNormal text"))
(should (stringp (wttrin--process-weather-content input)))))
-(ert-deftest test-wttrin--process-weather-content-error-very-long-line ()
+(ert-deftest test-wttrin--process-weather-content-error-very-long-line-returns-unchanged ()
"Test processing very long line without errors."
(let ((long-line (make-string 10000 ?x)))
(should (string= long-line (wttrin--process-weather-content long-line)))))