diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-05 12:23:29 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-05 12:23:29 -0500 |
| commit | ef8d5819b3cab677828e2ac21e780c78227acedb (patch) | |
| tree | 96d1cd80fc546b4344ada56828f7afd70fb47a29 /tests | |
| parent | 68877f04c2ceb569ae5cd74b8303b84b36ced1c5 (diff) | |
| download | chime-ef8d5819b3cab677828e2ac21e780c78227acedb.tar.gz chime-ef8d5819b3cab677828e2ac21e780c78227acedb.zip | |
refactor!: drop chime-play-sound, use chime-sound-file = nil to disable
`chime-play-sound' was redundant with `chime-sound-file' — both had to be
truthy for sound to play, and `chime-sound-file' already documented "set
to nil to disable sound completely". Two knobs for one decision is a
trap.
I removed the defcustom and the `(when chime-play-sound ...)' guard in
`chime--notify' (it now just checks `chime-sound-file'). Tests, README
quick-start, and the troubleshooting checklist all reference the new
single-knob form. One redundant test (sound-disabled-via-the-toggle)
got dropped because it now duplicates the sound-file-nil case.
Breaking change: users with `(setq chime-play-sound nil)' in their
config will get a void-variable warning at customize time and lose
their disable. Migration: `(setq chime-sound-file nil)'.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-chime-notify.el | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/tests/test-chime-notify.el b/tests/test-chime-notify.el index 61144c0..cd7b350 100644 --- a/tests/test-chime-notify.el +++ b/tests/test-chime-notify.el @@ -38,7 +38,6 @@ (setq chime-notification-title "Agenda") (setq chime-notification-icon nil) (setq chime-extra-alert-plist nil) - (setq chime-play-sound t) ;; Use a simple test path for sound file (setq chime-sound-file "/tmp/test-chime.wav")) @@ -55,7 +54,7 @@ (let ((sound-played nil) (alert-called nil) (alert-message nil)) - (cl-letf* ((chime-play-sound t) + (cl-letf* ( (chime-sound-file (expand-file-name "test-sound.wav" chime-test-base-dir)) ;; Mock file-exists-p to return t ((symbol-function 'file-exists-p) (lambda (file) t)) @@ -82,7 +81,7 @@ (unwind-protect (let ((beep-called nil) (alert-called nil)) - (cl-letf* ((chime-play-sound t) + (cl-letf* ( (chime-sound-file nil) ;; Mock beep to track if called ((symbol-function 'beep) @@ -97,34 +96,12 @@ (should alert-called))) (test-chime-notify-teardown))) -(ert-deftest test-chime-notify-no-sound-when-disabled () - "Test that no sound is played when chime-play-sound is nil." - (test-chime-notify-setup) - (unwind-protect - (let ((sound-played nil) - (beep-called nil) - (alert-called nil)) - (cl-letf* ((chime-play-sound nil) - ((symbol-function 'play-sound-file) - (lambda (file) (setq sound-played t))) - ((symbol-function 'beep) - (lambda () (setq beep-called t))) - ((symbol-function 'alert) - (lambda (msg &rest args) (setq alert-called t)))) - (chime--notify "Daily Standup") - ;; Should NOT play sound or beep - (should-not sound-played) - (should-not beep-called) - ;; Should still show alert - (should alert-called))) - (test-chime-notify-teardown))) - (ert-deftest test-chime-notify-passes-correct-parameters-to-alert () "Test that alert is called with correct parameters." (test-chime-notify-setup) (unwind-protect (let ((alert-params nil)) - (cl-letf* ((chime-play-sound nil) + (cl-letf* ( (chime-notification-title "Custom Title") (chime-notification-icon "/path/to/icon.png") (chime-extra-alert-plist '(:persistent t)) @@ -150,7 +127,7 @@ (unwind-protect (let ((alert-called nil) (alert-message nil)) - (cl-letf* ((chime-play-sound nil) + (cl-letf* ( ((symbol-function 'alert) (lambda (msg &rest args) (setq alert-called t) @@ -167,7 +144,7 @@ (unwind-protect (let ((sound-played nil) (alert-called nil)) - (cl-letf* ((chime-play-sound t) + (cl-letf* ( (chime-sound-file "/nonexistent/path/sound.wav") ;; Mock file-exists-p to return nil ((symbol-function 'file-exists-p) (lambda (file) nil)) @@ -189,7 +166,7 @@ (test-chime-notify-setup) (unwind-protect (let ((alert-called nil)) - (cl-letf* ((chime-play-sound t) + (cl-letf* ( (chime-sound-file "/some/file.wav") ;; Mock file-exists-p to return t ((symbol-function 'file-exists-p) (lambda (file) t)) @@ -211,7 +188,7 @@ (test-chime-notify-setup) (unwind-protect (let ((alert-called nil)) - (cl-letf* ((chime-play-sound t) + (cl-letf* ( (chime-sound-file nil) ;; Mock beep to throw error ((symbol-function 'beep) @@ -231,7 +208,7 @@ (test-chime-notify-setup) (unwind-protect (let ((alert-called nil)) - (cl-letf* ((chime-play-sound nil) + (cl-letf* ( ((symbol-function 'alert) (lambda (msg &rest args) (setq alert-called t)))) ;; Should not error with nil message |
