aboutsummaryrefslogtreecommitdiff
path: root/tests/test-gloss-display--show-entry-smoke.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-29 23:59:30 -0500
committerCraig Jennings <c@cjennings.net>2026-04-29 23:59:30 -0500
commit735ecf082273c0cba2f5c5dd25876e2ccd83b0f7 (patch)
tree5cdaca8277f0d2397682d4279fd5fbaa2e8e3162 /tests/test-gloss-display--show-entry-smoke.el
parent01b75599a500d6276a962b47744166abb25d846c (diff)
downloadgloss-735ecf082273c0cba2f5c5dd25876e2ccd83b0f7.tar.gz
gloss-735ecf082273c0cba2f5c5dd25876e2ccd83b0f7.zip
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.
Diffstat (limited to 'tests/test-gloss-display--show-entry-smoke.el')
-rw-r--r--tests/test-gloss-display--show-entry-smoke.el47
1 files changed, 47 insertions, 0 deletions
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