diff options
Diffstat (limited to 'tests/test-gloss-display--show-entry-smoke.el')
| -rw-r--r-- | tests/test-gloss-display--show-entry-smoke.el | 47 |
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 |
