diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-pearl-glyphs.el | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/tests/test-pearl-glyphs.el b/tests/test-pearl-glyphs.el index 78a4c2d..c2e9e7f 100644 --- a/tests/test-pearl-glyphs.el +++ b/tests/test-pearl-glyphs.el @@ -48,14 +48,23 @@ (ert-deftest test-pearl-heading-glyph-comment-wins () "A comment id selects the comment glyph even when an issue id is also present." - (should (equal (pearl--heading-glyph "c1" "i1") pearl--comment-glyph))) + (should (equal (pearl--heading-glyph "c1" "i1") pearl-comment-glyph))) (ert-deftest test-pearl-heading-glyph-issue () "An issue id with no comment id selects the ticket glyph." - (should (equal (pearl--heading-glyph nil "i1") pearl--ticket-glyph))) + (should (equal (pearl--heading-glyph nil "i1") pearl-ticket-glyph))) + +(ert-deftest test-pearl-heading-glyph-header () + "No id but the header flag selects the Comments-header glyph." + (should (equal (pearl--heading-glyph nil nil t) pearl-comments-header-glyph))) + +(ert-deftest test-pearl-heading-glyph-id-wins-over-header () + "A Linear id outranks the header flag." + (should (equal (pearl--heading-glyph "c1" nil t) pearl-comment-glyph)) + (should (equal (pearl--heading-glyph nil "i1" t) pearl-ticket-glyph))) (ert-deftest test-pearl-heading-glyph-none () - "A heading with neither id gets no glyph." + "A heading with no id and no header flag gets no glyph." (should (null (pearl--heading-glyph nil nil)))) ;;; --apply-heading-glyphs (overlay placement) @@ -68,7 +77,7 @@ (pearl--apply-heading-glyphs) (let ((ovs (test-pearl-glyphs--overlays))) (should (= (length ovs) 1)) - (should (string-match-p (regexp-quote pearl--ticket-glyph) + (should (string-match-p (regexp-quote pearl-ticket-glyph) (overlay-get (car ovs) 'display))))))) (ert-deftest test-pearl-apply-glyphs-comment-heading () @@ -79,9 +88,30 @@ (pearl--apply-heading-glyphs) (let ((ovs (test-pearl-glyphs--overlays))) (should (= (length ovs) 1)) - (should (string-match-p (regexp-quote pearl--comment-glyph) + (should (string-match-p (regexp-quote pearl-comment-glyph) (overlay-get (car ovs) 'display))))))) +(ert-deftest test-pearl-apply-glyphs-comments-header () + "The Comments container heading (no Linear id) gets the header-glyph overlay." + (test-pearl-glyphs--in-org + "*** Comments 2/2\n" + (let ((pearl-show-glyphs t) + (pearl-comments-header-glyph "๐ฌ")) + (pearl--apply-heading-glyphs) + (let ((ovs (test-pearl-glyphs--overlays))) + (should (= (length ovs) 1)) + (should (string-match-p (regexp-quote "๐ฌ") + (overlay-get (car ovs) 'display))))))) + +(ert-deftest test-pearl-apply-glyphs-empty-comment-glyph-none () + "An empty `pearl-comment-glyph' lays no overlay on a comment heading." + (test-pearl-glyphs--in-org + "**** Craig โ 2026-05-23\n:PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:END:\n" + (let ((pearl-show-glyphs t) + (pearl-comment-glyph "")) + (pearl--apply-heading-glyphs) + (should (null (test-pearl-glyphs--overlays)))))) + (ert-deftest test-pearl-apply-glyphs-plain-heading-none () "A heading with no Linear drawer gets no glyph overlay." (test-pearl-glyphs--in-org @@ -110,17 +140,34 @@ (should (null (test-pearl-glyphs--overlays)))))) (ert-deftest test-pearl-apply-glyphs-mixed-buffer () - "Issue and comment headings each get their own glyph; the count matches." + "Issue, Comments container, and comment headings each get their own glyph." (test-pearl-glyphs--in-org (concat "* TODO SE-1: title\n:PROPERTIES:\n:LINEAR-ID: i1\n:END:\n" - "** ๐ฌ Comments\n" + "** Comments 1/1\n" "*** Craig โ 2026-05-23\n:PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:END:\n") (let ((pearl-show-glyphs t)) (pearl--apply-heading-glyphs) (let ((ovs (test-pearl-glyphs--overlays))) - ;; Two glyphed headings: the issue and the one real comment. The - ;; "Comments" container carries no Linear id, so it gets nothing. - (should (= (length ovs) 2)))))) + ;; Three glyphed headings: the issue (ticket), the Comments container + ;; (header glyph, matched by regex since it carries no id), and the one + ;; real comment (speech). + (should (= (length ovs) 3)))))) + +;;; --comments-heading-regexp (glyph-agnostic Comments-header matcher) + +(ert-deftest test-pearl-comments-heading-regexp-tolerates-any-glyph () + "The Comments-heading regexp matches bare, glyphed, counted, and legacy forms." + (dolist (h '("*** Comments" + "*** Comments 2/2" + "*** Comments 2/2+" + "*** ๐ฌ Comments" + "*** ๐ฌ Comments 2/2" + "*** ๐จ๏ธ Comments 1/1" + "**** ๐งต Comments" + "*** Comments ๐ฌ 1/1")) ; pre-2026-05 trailing-glyph layout + (should (string-match-p pearl--comments-heading-regexp h))) + ;; Body prose that merely mentions Comments must not match. + (should-not (string-match-p pearl--comments-heading-regexp "Comments are nice"))) (provide 'test-pearl-glyphs) ;;; test-pearl-glyphs.el ends here |
