aboutsummaryrefslogtreecommitdiff
path: root/tests/test-chime-time-left.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 12:30:42 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 12:30:42 -0500
commit26fabb22edfea51e8a686c179ab91d00a2ff0bc3 (patch)
tree7c88db65289ef51ca2109bbaf6c5c887af382829 /tests/test-chime-time-left.el
parent0b65f607102c12260c7cca5df3d8586c2b1a24bd (diff)
downloadchime-26fabb22edfea51e8a686c179ab91d00a2ff0bc3.tar.gz
chime-26fabb22edfea51e8a686c179ab91d00a2ff0bc3.zip
refactor!: collapse three time-left format defcustoms into one alist
I merged `chime-time-left-format-at-event', `chime-time-left-format-short', and `chime-time-left-format-long' into a single alist `chime-time-left-formats' keyed by `at-event' / `short' / `long'. Three knobs for one feature (countdown display) was unnecessary surface area; one alist is the same flexibility with a third the namespace. `chime--time-left' switched from a pcase-on-variable to a pcase-on-regime that picks an alist key, then `alist-get's the format string. Behavior is identical for default settings. Test setup in the four affected files now builds the alist with `(list (cons 'KEY VAL) ...)' instead of `'(...)'. The literal-quote form returns the SAME cons-cell structure on every evaluation, so a previous test mutating it via `setf' on `alist-get' poisoned later tests. `list' + `cons' produces fresh structure per call, which is what the tests actually need. Migration: `(setq chime-time-left-format-short "in %mm")' becomes `(setf (alist-get 'short chime-time-left-formats) "in %mm")', or a full `(setq chime-time-left-formats '((at-event . ...) (short . ...) (long . ...)))' replacement.
Diffstat (limited to 'tests/test-chime-time-left.el')
-rw-r--r--tests/test-chime-time-left.el21
1 files changed, 11 insertions, 10 deletions
diff --git a/tests/test-chime-time-left.el b/tests/test-chime-time-left.el
index 25b41d9..b9bd176 100644
--- a/tests/test-chime-time-left.el
+++ b/tests/test-chime-time-left.el
@@ -35,9 +35,10 @@
"Setup function run before each test."
(chime-create-test-base-dir)
;; Reset format strings to defaults
- (setq chime-time-left-format-at-event "right now")
- (setq chime-time-left-format-short "in %M")
- (setq chime-time-left-format-long "in %H %M"))
+ (setq chime-time-left-formats
+ (list (cons 'at-event "right now")
+ (cons 'short "in %M")
+ (cons 'long "in %H %M"))))
(defun test-chime-time-left-teardown ()
"Teardown function run after each test."
@@ -216,7 +217,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-short "in %mm")
+ (setf (alist-get 'short chime-time-left-formats) "in %mm")
(let ((result (chime--time-left 300))) ; 5 minutes
(should (stringp result))
(should (string-equal "in 5m" result))))
@@ -227,7 +228,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-long "in %hh %mm")
+ (setf (alist-get 'long chime-time-left-formats) "in %hh %mm")
(let ((result (chime--time-left 5820))) ; 1 hour 37 minutes
(should (stringp result))
(should (string-equal "in 1h 37m" result))))
@@ -238,7 +239,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-long "(%h hr %m min)")
+ (setf (alist-get 'long chime-time-left-formats) "(%h hr %m min)")
(let ((result (chime--time-left 5820))) ; 1 hour 37 minutes
(should (stringp result))
(should (string-equal "(1 hr 37 min)" result))))
@@ -249,7 +250,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-long "%hh%mm")
+ (setf (alist-get 'long chime-time-left-formats) "%hh%mm")
(let ((result (chime--time-left 5820))) ; 1 hour 37 minutes
(should (stringp result))
(should (string-equal "1h37m" result))))
@@ -260,7 +261,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-at-event "NOW!")
+ (setf (alist-get 'at-event chime-time-left-formats) "NOW!")
(let ((result (chime--time-left 0)))
(should (stringp result))
(should (string-equal "NOW!" result))))
@@ -271,7 +272,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-short "%m min")
+ (setf (alist-get 'short chime-time-left-formats) "%m min")
(let ((result (chime--time-left 300))) ; 5 minutes
(should (stringp result))
(should (string-equal "5 min" result))))
@@ -282,7 +283,7 @@
(test-chime-time-left-setup)
(unwind-protect
(progn
- (setq chime-time-left-format-long "🕐 %hh%mm")
+ (setf (alist-get 'long chime-time-left-formats) "🕐 %hh%mm")
(let ((result (chime--time-left 5820))) ; 1 hour 37 minutes
(should (stringp result))
(should (string-equal "🕐 1h37m" result))))