diff options
Diffstat (limited to 'tests/test-wttrin--mode-line-update-display.el')
| -rw-r--r-- | tests/test-wttrin--mode-line-update-display.el | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/test-wttrin--mode-line-update-display.el b/tests/test-wttrin--mode-line-update-display.el index 0635b5f..be066e7 100644 --- a/tests/test-wttrin--mode-line-update-display.el +++ b/tests/test-wttrin--mode-line-update-display.el @@ -170,7 +170,7 @@ (test-wttrin--mode-line-update-display-teardown))) (ert-deftest test-wttrin--mode-line-update-display-stale-emoji-dimmed () - "Stale data dims the emoji with gray foreground." + "Stale data dims the emoji via the `wttrin-mode-line-stale' face." (test-wttrin--mode-line-update-display-setup) (unwind-protect (let ((wttrin-mode-line-refresh-interval 900) @@ -178,13 +178,13 @@ (cl-letf (((symbol-function 'float-time) (lambda () 3000.0))) (setq wttrin--mode-line-cache (cons 1000.0 "Paris: X +61°F Clear")) (wttrin--mode-line-update-display) - ;; The emoji character should have a gray face + ;; The emoji character should inherit the stale face (let* ((str wttrin-mode-line-string) ;; Find the emoji position (after the space) (emoji-pos 1) (face (get-text-property emoji-pos 'face str))) (should face) - (should (equal (plist-get face :foreground) "gray60"))))) + (should (eq (plist-get face :inherit) 'wttrin-mode-line-stale))))) (test-wttrin--mode-line-update-display-teardown))) ;;; Boundary Cases @@ -223,7 +223,7 @@ trigger an emoji re-render so dimming matches the tooltip's staleness state." (wttrin--mode-line-update-display) ;; Emoji should NOT be dimmed (let ((face (get-text-property 1 'face wttrin-mode-line-string))) - (should-not (and face (equal (plist-get face :foreground) "gray60"))))) + (should-not (and face (eq (plist-get face :inherit) 'wttrin-mode-line-stale))))) ;; Time passes: data is now stale (age=2001, threshold=1800) ;; Invoke the tooltip (simulating a hover) — this should trigger a re-render @@ -233,7 +233,7 @@ trigger an emoji re-render so dimming matches the tooltip's staleness state." ;; After hover detected staleness transition, emoji should now be dimmed (let ((face (get-text-property 1 'face wttrin-mode-line-string))) (should face) - (should (equal (plist-get face :foreground) "gray60"))))) + (should (eq (plist-get face :inherit) 'wttrin-mode-line-stale))))) (test-wttrin--mode-line-update-display-teardown))) ;;; -------------------------------------------------------------------------- @@ -252,6 +252,30 @@ trigger an emoji re-render so dimming matches the tooltip's staleness state." (should wttrin-mode-line-string))) (test-wttrin--mode-line-update-display-teardown))) +(ert-deftest test-wttrin--mode-line-fetch-weather-normal-saved-name-shown-in-cache () + "Normal: a saved-name favorite caches its display name, not the resolved query. +The query (coordinates or an address) drives the fetch, but the hover tooltip +should read the friendly name the user gave the place." + (test-wttrin--mode-line-update-display-setup) + (unwind-protect + (let ((wttrin-saved-locations '(("Mom's House" . "40.71,-74.01"))) + (wttrin-favorite-location "Mom's House")) + (testutil-wttrin-mock-http-response "40.71,-74.01: ☀️ +70°F Cloudy" + (wttrin--mode-line-fetch-weather) + (should (string-prefix-p "Mom's House:" (cdr wttrin--mode-line-cache))))) + (test-wttrin--mode-line-update-display-teardown))) + +(ert-deftest test-wttrin--mode-line-fetch-weather-boundary-plain-location-unchanged () + "Boundary: a plain (non-saved) favorite still caches its own name as the prefix." + (test-wttrin--mode-line-update-display-setup) + (unwind-protect + (let ((wttrin-saved-locations nil) + (wttrin-favorite-location "Paris")) + (testutil-wttrin-mock-http-response "Paris: ☀️ +61°F Clear" + (wttrin--mode-line-fetch-weather) + (should (string-prefix-p "Paris:" (cdr wttrin--mode-line-cache))))) + (test-wttrin--mode-line-update-display-teardown))) + (ert-deftest test-wttrin--mode-line-fetch-weather-error-empty-response-keeps-previous () "Empty API response does not overwrite previous valid cache." (test-wttrin--mode-line-update-display-setup) |
