From 28b7e4cecadce207d532b8d42346c3823450a35f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 17 Feb 2026 19:14:14 -0600 Subject: refactor: tests: standardize naming, consolidate files, and expand testutil - Expand testutil-wttrin.el with shared fixtures and macros (testutil-wttrin-with-clean-weather-buffer, testutil-wttrin-mock-http-response, sample ANSI/weather constants) - Consolidate cache tests: port unique tests from cleanup-cache-constants and cleanup-cache-refactored into cleanup-cache-if-needed, delete obsolete files - Extract startup-delay tests into dedicated file - Add setup/teardown and (require 'testutil-wttrin) to all test files - Rename all 160 tests to follow test---- convention - Rename integration test file and add detailed docstrings - Update Makefile glob to discover new integration test naming pattern Co-Authored-By: Claude Opus 4.6 --- tests/test-wttrin--display-weather.el | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'tests/test-wttrin--display-weather.el') diff --git a/tests/test-wttrin--display-weather.el b/tests/test-wttrin--display-weather.el index 4b2a90d..54de04f 100644 --- a/tests/test-wttrin--display-weather.el +++ b/tests/test-wttrin--display-weather.el @@ -39,14 +39,12 @@ Weather report: Paris, France (defun test-wttrin--display-weather-setup () "Setup for display weather tests." (testutil-wttrin-setup) - ;; Kill any existing weather buffer (when (get-buffer "*wttr.in*") (kill-buffer "*wttr.in*"))) (defun test-wttrin--display-weather-teardown () "Teardown for display weather tests." (testutil-wttrin-teardown) - ;; Clean up weather buffer (when (get-buffer "*wttr.in*") (kill-buffer "*wttr.in*"))) @@ -56,7 +54,7 @@ Weather report: Paris, France "Test that valid weather data creates and displays buffer correctly." (test-wttrin--display-weather-setup) (unwind-protect - (progn + (testutil-wttrin-with-clean-weather-buffer (wttrin--display-weather "Paris, France" test-wttrin--display-weather-sample-raw-data) ;; Buffer should exist @@ -80,7 +78,7 @@ Weather report: Paris, France "Test that keybindings are properly set up in weather buffer." (test-wttrin--display-weather-setup) (unwind-protect - (progn + (testutil-wttrin-with-clean-weather-buffer (wttrin--display-weather "London" test-wttrin--display-weather-sample-raw-data) (with-current-buffer "*wttr.in*" @@ -95,7 +93,7 @@ Weather report: Paris, France "Test that help instructions are displayed at bottom of buffer." (test-wttrin--display-weather-setup) (unwind-protect - (progn + (testutil-wttrin-with-clean-weather-buffer (wttrin--display-weather "Tokyo" test-wttrin--display-weather-sample-raw-data) (with-current-buffer "*wttr.in*" @@ -114,7 +112,7 @@ Weather report: Paris, France "Test that empty location name still creates buffer." (test-wttrin--display-weather-setup) (unwind-protect - (progn + (testutil-wttrin-with-clean-weather-buffer (wttrin--display-weather "" test-wttrin--display-weather-sample-raw-data) ;; Buffer should still be created @@ -129,7 +127,7 @@ Weather report: Paris, France "Test that location with special characters creates buffer." (test-wttrin--display-weather-setup) (unwind-protect - (progn + (testutil-wttrin-with-clean-weather-buffer (wttrin--display-weather "São Paulo, BR 🌆" test-wttrin--display-weather-sample-raw-data) (should (get-buffer "*wttr.in*")) @@ -144,15 +142,13 @@ Weather report: Paris, France Empty string does not match ERROR pattern, so it's processed as data." (test-wttrin--display-weather-setup) (unwind-protect - (progn + (testutil-wttrin-with-clean-weather-buffer (wttrin--display-weather "Paris" "") ;; Empty string is not treated as error, buffer is created (should (get-buffer "*wttr.in*")) (with-current-buffer "*wttr.in*" - ;; Buffer exists but will have minimal/broken content - ;; Just verify it was created and made read-only (should buffer-read-only))) (test-wttrin--display-weather-teardown))) @@ -163,7 +159,6 @@ Empty string does not match ERROR pattern, so it's processed as data." (test-wttrin--display-weather-setup) (unwind-protect (progn - ;; Capture message output (let ((message-log-max t) (message-displayed nil)) (cl-letf (((symbol-function 'message) @@ -198,13 +193,9 @@ Empty string does not match ERROR pattern, so it's processed as data." (test-wttrin--display-weather-setup) (unwind-protect (progn - ;; Suppress message output (cl-letf (((symbol-function 'message) (lambda (&rest _) nil))) (wttrin--display-weather "InvalidCity" nil) - ;; Buffer should not be created for error case - ;; (or if it exists from before, it shouldn't be switched to) - ;; This is testing the error path doesn't create/switch to buffer (should-not (string-match-p "wttr.in" (buffer-name (current-buffer)))))) (test-wttrin--display-weather-teardown))) -- cgit v1.2.3