From 735ecf082273c0cba2f5c5dd25876e2ccd83b0f7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 29 Apr 2026 23:59:30 -0500 Subject: test: add gloss-display test suite (red phase) Four test files covering the gloss-display public API and pure helpers. All 23 tests fail at this commit because the implementation is still a stub. Format-candidate gets full N/B/E coverage. Render-entry gets the pure-helper treatment. Pick-definition mocks completing-read at the boundary. Show-entry has a single smoke test. --- tests/test-gloss-display--show-entry-smoke.el | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/test-gloss-display--show-entry-smoke.el (limited to 'tests/test-gloss-display--show-entry-smoke.el') diff --git a/tests/test-gloss-display--show-entry-smoke.el b/tests/test-gloss-display--show-entry-smoke.el new file mode 100644 index 0000000..07d7a97 --- /dev/null +++ b/tests/test-gloss-display--show-entry-smoke.el @@ -0,0 +1,47 @@ +;;; test-gloss-display--show-entry-smoke.el --- Smoke test for gloss-display-show-entry -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Smoke test for `gloss-display-show-entry'. Exercises the side-buffer +;; setup end to end: buffer creation, content rendering, mode activation, +;; and the read-only invariant. Per the design and project testing rules, +;; framework primitives like `display-buffer' and major-mode mechanics are +;; not re-tested. + +;;; Code: + +(require 'ert) +(require 'gloss-display) + +(defmacro gloss-test--with-display-buffer-mocked (&rest body) + "Run BODY with `display-buffer' replaced by a no-op. +Avoids opening a real side window during batch tests, while still letting +`gloss-display-show-entry' populate and configure the entry buffer." + (declare (indent 0) (debug t)) + `(cl-letf (((symbol-function 'display-buffer) + (lambda (buffer &rest _args) (get-buffer buffer)))) + ,@body)) + +(ert-deftest test-gloss-display-show-entry-creates-buffer-with-mode-and-content () + "Smoke: show-entry creates a named buffer in `gloss-mode' with the entry." + (gloss-test--with-display-buffer-mocked + (unwind-protect + (let ((buf (gloss-display-show-entry + "anaphora" + "Reference to something earlier in the discourse."))) + (should (buffer-live-p buf)) + (with-current-buffer buf + (should (derived-mode-p 'gloss-mode)) + (should buffer-read-only) + (let ((contents (buffer-substring-no-properties + (point-min) (point-max)))) + (should (string-match-p "anaphora" contents)) + (should (string-match-p "Reference to something earlier" + contents))))) + (when-let ((buf (get-buffer "*gloss: anaphora*"))) + (let ((kill-buffer-query-functions nil)) + (kill-buffer buf)))))) + +(provide 'test-gloss-display--show-entry-smoke) +;;; test-gloss-display--show-entry-smoke.el ends here -- cgit v1.2.3