From 69c8deb2d7821c78475dcbb08458df6b0e56d559 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 12:40:27 -0500 Subject: 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 --- tests/test-chime-log-silently.el | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/test-chime-log-silently.el (limited to 'tests/test-chime-log-silently.el') 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 + +;; 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 . + +;;; 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 -- cgit v1.2.3