diff --git a/tests/test-org-roam-node.el b/tests/test-org-roam-node.el index 8f71c5d..31972b0 100644 --- a/tests/test-org-roam-node.el +++ b/tests/test-org-roam-node.el @@ -73,14 +73,16 @@ (expect (org-roam-node-title node) :to-equal "Bruce Wayne")))) (describe "org-roam-demote-entire-buffer" - (after-each - (cd root-directory)) - (it "demotes an entire org buffer" - (find-file "tests/roam-files/demoteable.org" nil) - (org-roam-demote-entire-buffer) - (expect (buffer-substring-no-properties (point) (point-max)) - :to-equal "* Demoteable\n:PROPERTIES:\n:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734\n:END:\n\n** Demoteable h1\n\n*** Demoteable child\n"))) + ;; Use a temporary copy to avoid interfering with other tests + (let ((temp-file (make-temp-file "test-demoteable-" nil ".org"))) + (copy-file "tests/roam-files/demoteable.org" temp-file t) + (find-file temp-file) + (org-roam-demote-entire-buffer) + (expect (buffer-substring-no-properties (point) (point-max)) + :to-equal "* Demoteable\n:PROPERTIES:\n:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734\n:END:\n\n** Demoteable h1\n\n*** Demoteable child\n") + (kill-buffer) + (delete-file temp-file)))) (describe "org-roam--h1-count" (after-each