(test): add org-roam-id-at-point (#2451)

This commit is contained in:
Bruno Heridet
2024-07-07 15:41:00 +02:00
committed by GitHub
parent 74d714f789
commit 76df9d1f3c
3 changed files with 37 additions and 2 deletions

View File

@ -59,3 +59,5 @@
:to-equal "foo"))) :to-equal "foo")))
(provide 'test-org-roam-capture) (provide 'test-org-roam-capture)
;;; test-org-roam-capture.el ends here

View File

@ -24,14 +24,43 @@
(require 'buttercup) (require 'buttercup)
(require 'org-roam) (require 'org-roam)
(describe "org-roam-id-find" (defvar root-directory default-directory)
(before-each
(describe "org-roam-id-at-point"
(before-all
(setq org-roam-directory (expand-file-name "tests/roam-files") (setq org-roam-directory (expand-file-name "tests/roam-files")
org-roam-db-location (expand-file-name "org-roam.db" temporary-file-directory) org-roam-db-location (expand-file-name "org-roam.db" temporary-file-directory)
org-roam-file-extensions '("org") org-roam-file-extensions '("org")
org-roam-file-exclude-regexp nil) org-roam-file-exclude-regexp nil)
(org-roam-db-sync)) (org-roam-db-sync))
(after-all
(org-roam-db--close)
(delete-file org-roam-db-location)
(cd root-directory))
(it "returns the correct node ids"
(find-file "tests/roam-files/family.org" nil)
(expect (org-roam-id-at-point) :to-equal "998b2341-b7fe-434d-848c-5282c0727870")
(search-forward "Grand")
(expect (org-roam-id-at-point) :to-equal "77a90980-1994-464e-901f-7e3d3df07fd3")
(search-forward "Child")
(expect (org-roam-id-at-point) :to-equal "5fb4fdc5-b6d2-4f75-8d54-e60053e467ec")))
(describe "org-roam-id-find"
(before-all
(setq org-roam-directory (expand-file-name "tests/roam-files")
org-roam-db-location (expand-file-name "org-roam.db" temporary-file-directory)
org-roam-file-extensions '("org")
org-roam-file-exclude-regexp nil)
(org-roam-db-sync))
(after-all
(org-roam-db--close)
(delete-file org-roam-db-location))
(it "finds nothing for non-existing node" (it "finds nothing for non-existing node"
(expect (org-roam-id-find "non-existing") :to-equal nil)) (expect (org-roam-id-find "non-existing") :to-equal nil))

View File

@ -31,6 +31,10 @@
org-roam-file-extensions '("org") org-roam-file-extensions '("org")
org-roam-file-exclude-regexp nil)) org-roam-file-exclude-regexp nil))
(after-all
(org-roam-db--close)
(delete-file org-roam-db-location))
(it "gets files correctly" (it "gets files correctly"
(expect (length (org-roam-list-files)) (expect (length (org-roam-list-files))
:to-equal 5)) :to-equal 5))