aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin--mode-line-update-display.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-04 13:07:50 -0500
committerCraig Jennings <c@cjennings.net>2026-04-04 13:07:50 -0500
commitf526cf641181e9cdb533a1f8a278de1fad49ca25 (patch)
treef966ffbfa921a0f3ddb33e3e301845ed11c24db7 /tests/test-wttrin--mode-line-update-display.el
parent25b760d805e98ff3c0f0f9b29f75a108fb1dce10 (diff)
downloademacs-wttrin-f526cf641181e9cdb533a1f8a278de1fad49ca25.tar.gz
emacs-wttrin-f526cf641181e9cdb533a1f8a278de1fad49ca25.zip
fix: mode-line tooltip always shows "Updated just now"
The tooltip was a static string computed at fetch time. Since every successful fetch sets the cache timestamp to now and immediately renders the tooltip, it was always "just now". Extract wttrin--mode-line-tooltip as a named function that computes age from the cache at call time. Set help-echo to this function so Emacs invokes it on hover, producing an accurate age like "Updated 12 minutes ago".
Diffstat (limited to 'tests/test-wttrin--mode-line-update-display.el')
-rw-r--r--tests/test-wttrin--mode-line-update-display.el6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/test-wttrin--mode-line-update-display.el b/tests/test-wttrin--mode-line-update-display.el
index e23780b..81fbded 100644
--- a/tests/test-wttrin--mode-line-update-display.el
+++ b/tests/test-wttrin--mode-line-update-display.el
@@ -146,7 +146,8 @@
(cl-letf (((symbol-function 'float-time) (lambda () 1300.0)))
(setq wttrin--mode-line-cache (cons 1000.0 "Paris: ☀️ +61°F Clear"))
(wttrin--mode-line-update-display)
- (let ((tooltip (get-text-property 0 'help-echo wttrin-mode-line-string)))
+ (let* ((help-echo-fn (get-text-property 0 'help-echo wttrin-mode-line-string))
+ (tooltip (funcall help-echo-fn nil nil nil)))
(should (string-match-p "Paris" tooltip))
(should (string-match-p "Updated 5 minutes ago" tooltip))))
(test-wttrin--mode-line-update-display-teardown)))
@@ -162,7 +163,8 @@
;; Data is 2000 seconds old, threshold is 2*900=1800 -> stale
(setq wttrin--mode-line-cache (cons 1000.0 "Paris: ☀️ +61°F Clear"))
(wttrin--mode-line-update-display)
- (let ((tooltip (get-text-property 0 'help-echo wttrin-mode-line-string)))
+ (let* ((help-echo-fn (get-text-property 0 'help-echo wttrin-mode-line-string))
+ (tooltip (funcall help-echo-fn nil nil nil)))
(should (string-match-p "Stale" tooltip))
(should (string-match-p "fetch failed" tooltip)))))
(test-wttrin--mode-line-update-display-teardown)))