aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-comment-editing.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-pearl-comment-editing.el')
-rw-r--r--tests/test-pearl-comment-editing.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test-pearl-comment-editing.el b/tests/test-pearl-comment-editing.el
index 866366f..be65aa3 100644
--- a/tests/test-pearl-comment-editing.el
+++ b/tests/test-pearl-comment-editing.el
@@ -256,5 +256,33 @@
(should (eq 'pearl-editable-comment (face-on "^\\*\\*\\*\\*\\* Me")))
(should (eq 'pearl-readonly-comment (face-on "^\\*\\*\\*\\*\\* Them"))))))
+(ert-deftest test-pearl-add-comment-from-inside-comment-refuses ()
+ "Running add-comment from inside a comment subtree refuses — no issue id there."
+ (test-pearl--in-org (test-pearl--comment-doc "u-me" "stored" "uniquecommentline")
+ (goto-char (point-min))
+ (re-search-forward "uniquecommentline") ; point inside the comment subtree
+ (should-error (pearl-add-comment "hi") :type 'user-error)))
+
+(ert-deftest test-pearl-edit-comment-missing-id-refuses-no-network ()
+ "A comment subtree without LINEAR-COMMENT-ID is refused with no network call."
+ (test-pearl--in-org
+ (concat "** TODO Issue\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody.\n"
+ "*** Comments\n**** Me — ts\n:PROPERTIES:\n:LINEAR-COMMENT-AUTHOR-ID: u-me\n:END:\nedited\n")
+ (let ((net nil))
+ (cl-letf (((symbol-function 'pearl--fetch-comment-body-async) (lambda (&rest _) (setq net t)))
+ ((symbol-function 'pearl--update-comment-async) (lambda (&rest _) (setq net t))))
+ (re-search-forward "edited")
+ (should-error (pearl-edit-current-comment) :type 'user-error)
+ (should-not net)))))
+
+(ert-deftest test-pearl-comment-body-reads-drawer-looking-text ()
+ "A comment body containing a colon-wrapped, drawer-looking line reads back intact."
+ (test-pearl--in-org
+ (concat "** TODO Issue\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody.\n"
+ "*** Comments\n**** Me — ts\n:PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:END:\n"
+ "see :note: below\nand more text\n")
+ (re-search-forward "see :note:")
+ (should (string= "see :note: below\nand more text" (pearl--issue-body-at-point)))))
+
(provide 'test-pearl-comment-editing)
;;; test-pearl-comment-editing.el ends here