diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-28 06:42:00 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-28 06:42:00 -0400 |
| commit | 16be44154cf823332332d1df995ae1ed50ff43c4 (patch) | |
| tree | 8f4b7fc73ae061fe67dfec2141ed0d0992937a0b /tests | |
| parent | da7ee0841924dfbd91c9a944e0bfeff6903bd8a1 (diff) | |
| download | emacs-wttrin-16be44154cf823332332d1df995ae1ed50ff43c4.tar.gz emacs-wttrin-16be44154cf823332332d1df995ae1ed50ff43c4.zip | |
fix: don't auto-fit the loading placeholder to a huge font
With auto-fit on, the one-line "Loading..." placeholder was sized to fill the
window height (capped huge), and a reused buffer kept the previous weather's
auto-fitted font while loading. Auto-fit now runs only once real weather has
rendered, and the placeholder resets to the base font.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-wttrin--update-layout.el | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test-wttrin--update-layout.el b/tests/test-wttrin--update-layout.el new file mode 100644 index 0000000..b8df665 --- /dev/null +++ b/tests/test-wttrin--update-layout.el @@ -0,0 +1,39 @@ +;;; test-wttrin--update-layout.el --- Auto-fit gating -*- lexical-binding: t; -*- + +;; Copyright (C) 2024-2026 Craig Jennings + +;;; Commentary: +;; Auto-fit must not size the transient "Loading..." placeholder to fill the +;; window; it runs only once real weather has rendered. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(require 'wttrin) +(require 'testutil-wttrin) + +(ert-deftest test-wttrin--update-layout-error-skips-fit-on-placeholder () + "Error: with auto-fit on, the loading placeholder (weather not rendered) is +not auto-fitted; the fit runs only after weather renders." + (let ((buf (get-buffer-create "*wttrin-layout-test*")) + (fit-calls 0)) + (unwind-protect + (save-window-excursion + (cl-letf (((symbol-function 'wttrin--apply-fit-font) + (lambda (&rest _) (setq fit-calls (1+ fit-calls)))) + ((symbol-function 'wttrin--center-buffer) #'ignore)) + (with-current-buffer buf (insert "Loading...")) + (set-window-buffer (selected-window) buf) + (with-current-buffer buf + (let ((wttrin-auto-fit-font t)) + (setq-local wttrin--weather-rendered nil) + (wttrin--update-layout) + (should (= 0 fit-calls)) + (setq-local wttrin--weather-rendered t) + (wttrin--update-layout) + (should (= 1 fit-calls)))))) + (kill-buffer buf)))) + +(provide 'test-wttrin--update-layout) +;;; test-wttrin--update-layout.el ends here |
