summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-04 16:37:11 -0500
committerCraig Jennings <c@cjennings.net>2026-04-04 16:37:11 -0500
commit5463f104165185501be9cd6f7458d1b0cad856de (patch)
tree453cd364d6ec93325235037aab96158900f9271e /tests
parent73c81a00a10766900318d86640249d1b54c6b351 (diff)
downloademacs-wttrin-5463f104165185501be9cd6f7458d1b0cad856de.tar.gz
emacs-wttrin-5463f104165185501be9cd6f7458d1b0cad856de.zip
fix: weather buffer shows location in lowercase
wttr.in returns "Weather report: new orleans, la" regardless of query casing. Replace the lowercase location on the header line with the user's original string after rendering.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-wttrin--display-weather.el43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test-wttrin--display-weather.el b/tests/test-wttrin--display-weather.el
index 6417995..b30c5b5 100644
--- a/tests/test-wttrin--display-weather.el
+++ b/tests/test-wttrin--display-weather.el
@@ -200,5 +200,48 @@ Empty string does not match ERROR pattern, so it's processed as data."
(buffer-name (current-buffer))))))
(test-wttrin--display-weather-teardown)))
+;;; Location Casing
+
+(ert-deftest test-wttrin--display-weather-normal-location-uses-user-casing ()
+ "The 'Weather report:' header should show the user's original casing,
+not the lowercase version that wttr.in returns."
+ (test-wttrin--display-weather-setup)
+ (unwind-protect
+ (testutil-wttrin-with-clean-weather-buffer
+ (wttrin--display-weather "New Orleans, LA"
+ "Weather report: new orleans, la\n\nSunny 72°F")
+ (with-current-buffer "*wttr.in*"
+ (let ((case-fold-search nil))
+ (goto-char (point-min))
+ (should (search-forward "New Orleans, LA" nil t))
+ (goto-char (point-min))
+ (should-not (search-forward "new orleans, la" nil t)))))
+ (test-wttrin--display-weather-teardown)))
+
+(ert-deftest test-wttrin--display-weather-boundary-location-already-correct ()
+ "When the API returns correct casing, nothing should break."
+ (test-wttrin--display-weather-setup)
+ (unwind-protect
+ (testutil-wttrin-with-clean-weather-buffer
+ (wttrin--display-weather "Paris"
+ "Weather report: Paris\n\nSunny 22°C")
+ (with-current-buffer "*wttr.in*"
+ (goto-char (point-min))
+ (should (search-forward "Paris" nil t))))
+ (test-wttrin--display-weather-teardown)))
+
+(ert-deftest test-wttrin--display-weather-normal-weather-data-preserved ()
+ "Fixing the location casing should not alter the weather data itself."
+ (test-wttrin--display-weather-setup)
+ (unwind-protect
+ (testutil-wttrin-with-clean-weather-buffer
+ (wttrin--display-weather "Tokyo"
+ "Weather report: tokyo\n\nCloudy 18°C\nWind: 5 km/h")
+ (with-current-buffer "*wttr.in*"
+ (let ((contents (buffer-string)))
+ (should (string-match-p "Cloudy 18°C" contents))
+ (should (string-match-p "Wind: 5 km/h" contents)))))
+ (test-wttrin--display-weather-teardown)))
+
(provide 'test-wttrin--display-weather)
;;; test-wttrin--display-weather.el ends here