From 9459a0b30f86adb9066312672c7bd96e70bc1f6f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 26 Jun 2026 12:39:36 -0400 Subject: feat: save the location to the directory when making it the default Pressing d on a typed or aliased location set the favorite but never added it to wttrin-saved-locations, so the default persisted only as the favorite string, not as a named directory entry. The coordinate branch already saved. The typed/alias branch did not. The typed/alias branch now puts the location into the directory before promoting it, so a typed default like "Reykjavik" persists as a ("Reykjavik" . "Reykjavik") entry. An empty-name coordinate detection still keeps the raw coordinates without saving an entry. --- tests/test-wttrin-saved-locations.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-wttrin-saved-locations.el b/tests/test-wttrin-saved-locations.el index 0a7b8b3..c2f44b8 100644 --- a/tests/test-wttrin-saved-locations.el +++ b/tests/test-wttrin-saved-locations.el @@ -300,7 +300,24 @@ now-deleted alias's resolved weather and re-fetches against the bare query." ((symbol-function 'message) (lambda (&rest _) nil))) (wttrin-make-default))) (should-not prompted) - (should (equal "Craig's House" wttrin-favorite-location)))) + (should (equal "Craig's House" wttrin-favorite-location)) + (should (equal "1500 Sugar Bowl Dr" + (wttrin--resolve-location-query "Craig's House"))))) + +(ert-deftest test-wttrin-saved-locations-normal-d-typed-saves-to-directory () + "Normal: making a typed location the default also saves it to the directory, +so it persists as a named entry rather than only as the favorite string." + (let ((wttrin-saved-locations nil) + (wttrin-favorite-location nil) + (wttrin-mode-line-mode nil)) + (with-temp-buffer + (setq-local wttrin--current-location "Reykjavik") + (setq-local wttrin--current-display "Reykjavik") + (cl-letf (((symbol-function 'message) (lambda (&rest _) nil))) + (wttrin-make-default))) + (should (equal "Reykjavik" wttrin-favorite-location)) + (should (assoc "Reykjavik" (wttrin--saved-locations))) + (should (equal "Reykjavik" (wttrin--resolve-location-query "Reykjavik"))))) ;;; interactive entry smoke tests (cover the prompt forms) -- cgit v1.2.3