diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-pearl-fetch-all-comments.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-pearl-fetch-all-comments.el b/tests/test-pearl-fetch-all-comments.el index 04dfe31..4449314 100644 --- a/tests/test-pearl-fetch-all-comments.el +++ b/tests/test-pearl-fetch-all-comments.el @@ -124,5 +124,30 @@ (test-pearl-fac--goto-issue) (should-not (pearl--unpushed-comment-edits-p)))) +;;; save-after-fetch helper + +(ert-deftest test-pearl-save-if-visiting-noop-without-file () + "In a non-file buffer the save helper is a no-op, not an error." + (with-temp-buffer + (insert "x") + (should-not (pearl--save-if-visiting)))) + +(ert-deftest test-pearl-save-if-visiting-saves-file-buffer () + "In a file-visiting buffer the helper writes the buffer to disk." + (let ((f (make-temp-file "pearl-save-" nil ".org"))) + (unwind-protect + (let ((buf (find-file-noselect f))) + (unwind-protect + (with-current-buffer buf + (insert "hello pearl") + (should (buffer-modified-p)) + (pearl--save-if-visiting) + (should-not (buffer-modified-p)) + (should (string-match-p + "hello pearl" + (with-temp-buffer (insert-file-contents f) (buffer-string))))) + (kill-buffer buf))) + (delete-file f)))) + (provide 'test-pearl-fetch-all-comments) ;;; test-pearl-fetch-all-comments.el ends here |
