diff options
| -rw-r--r-- | tests/test-wttrin-saved-locations.el | 19 | ||||
| -rw-r--r-- | wttrin.el | 13 |
2 files changed, 26 insertions, 6 deletions
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) @@ -1229,11 +1229,13 @@ here works whether or not savehist is loaded." (defun wttrin-make-default () "Make the location shown in this buffer the favorite (persisted) default. -A named buffer (a saved alias or a typed location) is promoted directly. A raw -coordinate buffer (a fresh geolocation detection) first prompts for a name, -prefilled with the detected address; the entered name is saved to the directory -and promoted. An empty name keeps the raw coordinates as the default. No-op -with a message when the buffer has no current location." +A named buffer (a saved alias or a typed location) is saved to the directory and +promoted, so the default also persists as a named entry rather than only the +favorite string. A raw coordinate buffer (a fresh geolocation detection) first +prompts for a name, prefilled with the detected address; the entered name is +saved and promoted. An empty name keeps the raw coordinates as the default +without saving a directory entry. No-op with a message when the buffer has no +current location." (interactive) (cond ((null wttrin--current-location) @@ -1251,6 +1253,7 @@ with a message when the buffer has no current location." (message "wttrin: %s is now the default location" name)))) (t (let ((favorite (or wttrin--current-display wttrin--current-location))) + (wttrin--put-saved-location favorite wttrin--current-location) (wttrin--set-favorite-location favorite) (message "wttrin: %s is now the default location" favorite))))) |
