diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-29 23:59:30 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-29 23:59:30 -0500 |
| commit | 735ecf082273c0cba2f5c5dd25876e2ccd83b0f7 (patch) | |
| tree | 5cdaca8277f0d2397682d4279fd5fbaa2e8e3162 /tests/test-gloss-display--render-entry.el | |
| parent | 01b75599a500d6276a962b47744166abb25d846c (diff) | |
| download | gloss-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--render-entry.el')
| -rw-r--r-- | tests/test-gloss-display--render-entry.el | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test-gloss-display--render-entry.el b/tests/test-gloss-display--render-entry.el new file mode 100644 index 0000000..5656660 --- /dev/null +++ b/tests/test-gloss-display--render-entry.el @@ -0,0 +1,64 @@ +;;; test-gloss-display--render-entry.el --- Tests for gloss-display--render-entry -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Tests for the pure helper `gloss-display--render-entry' covering +;; Normal/Boundary/Error cases. The helper takes a TERM and BODY and +;; returns the formatted string that `gloss-display-show-entry' inserts +;; into the side buffer. + +;;; Code: + +(require 'ert) +(require 'gloss-display) + +(ert-deftest test-gloss-display-render-entry-normal-term-and-body () + "Normal: render produces the term, an underline, a blank, and the body." + (let ((result (gloss-display--render-entry + "anaphora" + "Reference to something earlier in the discourse."))) + (should (string-match-p "^anaphora\n" result)) + (should (string-match-p "^=+\n" (substring result (length "anaphora\n")))) + (should (string-match-p "Reference to something earlier" result)))) + +(ert-deftest test-gloss-display-render-entry-normal-underline-matches-term-length () + "Normal: the underline length matches the term length." + (let* ((term "abc") + (result (gloss-display--render-entry term "Body.")) + (lines (split-string result "\n"))) + (should (equal (nth 0 lines) term)) + (should (= (length (nth 1 lines)) (length term))) + (should (string-match-p "^=+$" (nth 1 lines))))) + +(ert-deftest test-gloss-display-render-entry-boundary-multi-line-body () + "Boundary: a multi-line body is preserved verbatim." + (let ((result (gloss-display--render-entry + "term" + "First paragraph.\n\nSecond paragraph."))) + (should (string-match-p "First paragraph\\." result)) + (should (string-match-p "Second paragraph\\." result)) + (should (string-match-p "First paragraph\\.\n\nSecond paragraph\\." result)))) + +(ert-deftest test-gloss-display-render-entry-boundary-empty-body () + "Boundary: an empty body still renders the term and underline." + (let ((result (gloss-display--render-entry "lonely" ""))) + (should (string-match-p "^lonely\n=+\n" result)))) + +(ert-deftest test-gloss-display-render-entry-boundary-unicode-term () + "Boundary: unicode characters in the term are preserved." + (let* ((term "café") + (result (gloss-display--render-entry term "A coffeehouse."))) + (should (string-match-p (regexp-quote term) result)) + (should (string-match-p "A coffeehouse\\." result)))) + +(ert-deftest test-gloss-display-render-entry-boundary-very-long-term () + "Boundary: a long term gets a matching long underline." + (let* ((term (make-string 60 ?z)) + (result (gloss-display--render-entry term "Body.")) + (lines (split-string result "\n"))) + (should (equal (nth 0 lines) term)) + (should (= (length (nth 1 lines)) 60)))) + +(provide 'test-gloss-display--render-entry) +;;; test-gloss-display--render-entry.el ends here |
