aboutsummaryrefslogtreecommitdiff
path: root/tests/test-chime-log-silently.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-04 12:40:27 -0500
committerCraig Jennings <c@cjennings.net>2026-04-04 12:40:27 -0500
commit69c8deb2d7821c78475dcbb08458df6b0e56d559 (patch)
treea55c1d8b3fc723fc25bf5ca47f668902a47bf4ed /tests/test-chime-log-silently.el
parentfe5a31072bfa2f6451769008a63ad5b0d9a3de17 (diff)
downloadchime-69c8deb2d7821c78475dcbb08458df6b0e56d559.tar.gz
chime-69c8deb2d7821c78475dcbb08458df6b0e56d559.zip
Add 94 tests across 10 new test files and fix 2 bugs
New test coverage for previously untested functions: - filter-day-wide-events, time utilities, day-wide time matching - make-tooltip, event-is-today, get-tags, done-keywords-predicate - extract-title, propertize-modeline-string, warn-persistent-failures - log-silently Bug fixes discovered by new tests: - Fix pluralization in no-events tooltip ("1 hours" -> "1 hour", etc.) - Fix chime--get-tags returning ("") instead of nil for untagged headings
Diffstat (limited to 'tests/test-chime-log-silently.el')
-rw-r--r--tests/test-chime-log-silently.el88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/test-chime-log-silently.el b/tests/test-chime-log-silently.el
new file mode 100644
index 0000000..e08987f
--- /dev/null
+++ b/tests/test-chime-log-silently.el
@@ -0,0 +1,88 @@
+;;; test-chime-log-silently.el --- Tests for chime--log-silently -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024-2026 Craig Jennings
+
+;; Author: Craig Jennings <c@cjennings.net>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Unit tests for chime--log-silently function.
+;; This function writes to *Messages* buffer without echoing to minibuffer.
+
+;;; Code:
+
+;; Initialize package system for batch mode
+(when noninteractive
+ (package-initialize))
+
+(require 'ert)
+
+;; Load dependencies required by chime
+(require 'dash)
+(require 'alert)
+(require 'async)
+(require 'org-agenda)
+
+;; Load chime from parent directory
+(load (expand-file-name "../chime.el") nil t)
+
+;;; Normal Cases
+
+(ert-deftest test-chime-log-silently-writes-to-messages ()
+ "Should write the formatted text to *Messages* buffer."
+ (let ((messages-buf (get-buffer-create "*Messages*")))
+ (with-current-buffer messages-buf
+ (let ((pos-before (point-max)))
+ (chime--log-silently "Test log message")
+ (goto-char pos-before)
+ (should (search-forward "Test log message" nil t))))))
+
+(ert-deftest test-chime-log-silently-formats-with-args ()
+ "Should format with args like `format'."
+ (let ((messages-buf (get-buffer-create "*Messages*")))
+ (with-current-buffer messages-buf
+ (let ((pos-before (point-max)))
+ (chime--log-silently "Event count: %d, name: %s" 5 "Meeting")
+ (goto-char pos-before)
+ (should (search-forward "Event count: 5, name: Meeting" nil t))))))
+
+(ert-deftest test-chime-log-silently-multiple-calls-append ()
+ "Multiple calls should append sequentially."
+ (let ((messages-buf (get-buffer-create "*Messages*")))
+ (with-current-buffer messages-buf
+ (let ((pos-before (point-max)))
+ (chime--log-silently "First message")
+ (chime--log-silently "Second message")
+ (goto-char pos-before)
+ (let ((first-pos (search-forward "First message" nil t))
+ (second-pos (progn (goto-char pos-before)
+ (search-forward "Second message" nil t))))
+ (should first-pos)
+ (should second-pos)
+ ;; Second should come after first
+ (should (> second-pos first-pos)))))))
+
+;;; Boundary Cases
+
+(ert-deftest test-chime-log-silently-empty-format-string ()
+ "Empty format string should not error."
+ ;; Should not signal an error
+ (should-not (condition-case nil
+ (progn (chime--log-silently "") nil)
+ (error t))))
+
+(provide 'test-chime-log-silently)
+;;; test-chime-log-silently.el ends here