diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-17 19:14:14 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-17 19:14:14 -0600 |
| commit | 28b7e4cecadce207d532b8d42346c3823450a35f (patch) | |
| tree | 4d8772206e10c59762ae1e60343d4bc8dded77b5 /tests/test-wttrin--build-url.el | |
| parent | bf989bb594680eb2e3b69f55752353aa33cb47bb (diff) | |
| download | emacs-wttrin-28b7e4cecadce207d532b8d42346c3823450a35f.tar.gz emacs-wttrin-28b7e4cecadce207d532b8d42346c3823450a35f.zip | |
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-<module>-<category>-<scenario>-<expected-result> 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 <noreply@anthropic.com>
Diffstat (limited to 'tests/test-wttrin--build-url.el')
| -rw-r--r-- | tests/test-wttrin--build-url.el | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/tests/test-wttrin--build-url.el b/tests/test-wttrin--build-url.el index 87a5f92..46760bc 100644 --- a/tests/test-wttrin--build-url.el +++ b/tests/test-wttrin--build-url.el @@ -10,28 +10,39 @@ (require 'ert) (require 'wttrin) +(require 'testutil-wttrin) + +;;; Setup and Teardown + +(defun test-wttrin--build-url-setup () + "Setup for build-url tests." + (testutil-wttrin-setup)) + +(defun test-wttrin--build-url-teardown () + "Teardown for build-url tests." + (testutil-wttrin-teardown)) ;;; Normal Cases -(ert-deftest test-wttrin--build-url-normal-simple-city () +(ert-deftest test-wttrin--build-url-normal-simple-city-returns-correct-url () "Test URL building with simple city name." (let ((wttrin-unit-system nil)) (should (string= "https://wttr.in/Paris?A" (wttrin--build-url "Paris"))))) -(ert-deftest test-wttrin--build-url-normal-city-with-country () +(ert-deftest test-wttrin--build-url-normal-city-with-country-returns-encoded-url () "Test URL building with city and country code." (let ((wttrin-unit-system nil)) (should (string= "https://wttr.in/London%2C%20GB?A" (wttrin--build-url "London, GB"))))) -(ert-deftest test-wttrin--build-url-normal-metric-system () +(ert-deftest test-wttrin--build-url-normal-metric-system-includes-m-flag () "Test URL building with metric unit system." (let ((wttrin-unit-system "m")) (should (string= "https://wttr.in/Tokyo?mA" (wttrin--build-url "Tokyo"))))) -(ert-deftest test-wttrin--build-url-normal-imperial-system () +(ert-deftest test-wttrin--build-url-normal-imperial-system-includes-u-flag () "Test URL building with USCS/imperial unit system." (let ((wttrin-unit-system "u")) (should (string= "https://wttr.in/NewYork?uA" @@ -39,7 +50,7 @@ ;;; Boundary Cases -(ert-deftest test-wttrin--build-url-boundary-unicode-city-name () +(ert-deftest test-wttrin--build-url-boundary-unicode-city-name-returns-encoded-url () "Test URL building with Unicode characters in city name." (let ((wttrin-unit-system nil)) (let ((url (wttrin--build-url "北京"))) ; Beijing in Chinese @@ -47,32 +58,32 @@ (should (string-prefix-p "https://wttr.in/" url)) (should (string-suffix-p "?A" url))))) -(ert-deftest test-wttrin--build-url-boundary-special-characters () +(ert-deftest test-wttrin--build-url-boundary-special-characters-returns-encoded-url () "Test URL building with special characters requiring encoding." (let ((wttrin-unit-system nil)) (let ((url (wttrin--build-url "São Paulo"))) (should (string-match-p "https://wttr.in/S%C3%A3o%20Paulo\\?A" url))))) -(ert-deftest test-wttrin--build-url-boundary-spaces-encoded () +(ert-deftest test-wttrin--build-url-boundary-spaces-returns-percent-encoded () "Test that spaces in query are properly URL-encoded." (let ((wttrin-unit-system nil)) (let ((url (wttrin--build-url "New York"))) (should (string= "https://wttr.in/New%20York?A" url)) (should-not (string-match-p " " url))))) -(ert-deftest test-wttrin--build-url-boundary-airport-code () +(ert-deftest test-wttrin--build-url-boundary-airport-code-returns-correct-url () "Test URL building with 3-letter airport code." (let ((wttrin-unit-system nil)) (should (string= "https://wttr.in/SFO?A" (wttrin--build-url "SFO"))))) -(ert-deftest test-wttrin--build-url-boundary-gps-coordinates () +(ert-deftest test-wttrin--build-url-boundary-gps-coordinates-returns-correct-url () "Test URL building with GPS coordinates." (let ((wttrin-unit-system nil)) (let ((url (wttrin--build-url "-78.46,106.79"))) (should (string-match-p "https://wttr.in/-78\\.46.*106\\.79\\?A" url))))) -(ert-deftest test-wttrin--build-url-boundary-domain-name () +(ert-deftest test-wttrin--build-url-boundary-domain-name-returns-encoded-url () "Test URL building with domain name (wttr.in supports @domain). The @ symbol should be URL-encoded as %40." (let ((wttrin-unit-system nil)) @@ -88,7 +99,7 @@ The @ symbol should be URL-encoded as %40." (should-error (wttrin--build-url nil) :type 'error))) -(ert-deftest test-wttrin--build-url-error-nil-query-has-message () +(ert-deftest test-wttrin--build-url-error-nil-query-has-descriptive-message () "Test that nil query error has descriptive message." (let ((wttrin-unit-system nil)) (condition-case err |
