mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(test): add org-roam-demote-entire-buffer (#2459)
This commit is contained in:
8
tests/roam-files/demoteable.org
Normal file
8
tests/roam-files/demoteable.org
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734
|
||||||
|
:END:
|
||||||
|
#+title: Demoteable
|
||||||
|
|
||||||
|
* Demoteable h1
|
||||||
|
|
||||||
|
** Demoteable child
|
@ -1,5 +1,5 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 57FF3CE7-5BDA-4825-8FCA-C09F523E87BA
|
:ID: 57ff3ce7-5bda-4825-8fca-c09f523e87ba
|
||||||
:ROAM_ALIASES: Batman
|
:ROAM_ALIASES: Batman
|
||||||
:END:
|
:END:
|
||||||
#+title: Bruce Wayne
|
#+title: Bruce Wayne
|
||||||
|
@ -72,6 +72,16 @@
|
|||||||
(let ((node (org-roam-node-from-title-or-alias "batman" t)))
|
(let ((node (org-roam-node-from-title-or-alias "batman" t)))
|
||||||
(expect (org-roam-node-title node) :to-equal "Bruce Wayne"))))
|
(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")))
|
||||||
|
|
||||||
(describe "org-roam--h1-count"
|
(describe "org-roam--h1-count"
|
||||||
(after-each
|
(after-each
|
||||||
(cd root-directory))
|
(cd root-directory))
|
||||||
@ -118,7 +128,7 @@
|
|||||||
(it "returns the list of titles and aliases"
|
(it "returns the list of titles and aliases"
|
||||||
(expect (org-roam--get-titles)
|
(expect (org-roam--get-titles)
|
||||||
:to-have-same-items-as
|
:to-have-same-items-as
|
||||||
`("Bar" "Batman" "Bruce Wayne" "Child" "Family" "Foo" "Grand-Parent" "Parent" "ref with space"))))
|
`("Bar" "Batman" "Bruce Wayne" "Child" "Demoteable" "Family" "Foo" "Grand-Parent" "Parent" "ref with space"))))
|
||||||
|
|
||||||
(describe "org-roam-alias"
|
(describe "org-roam-alias"
|
||||||
(before-all
|
(before-all
|
||||||
@ -145,7 +155,7 @@
|
|||||||
(find-file "tests/roam-files/with-alias.org" nil)
|
(find-file "tests/roam-files/with-alias.org" nil)
|
||||||
(org-roam-alias-remove "Batman")
|
(org-roam-alias-remove "Batman")
|
||||||
(expect (buffer-substring-no-properties (point) (point-max))
|
(expect (buffer-substring-no-properties (point) (point-max))
|
||||||
:to-equal ":PROPERTIES:\n:ID: 57FF3CE7-5BDA-4825-8FCA-C09F523E87BA\n:END:\n#+title: Bruce Wayne\n")))
|
:to-equal ":PROPERTIES:\n:ID: 57ff3ce7-5bda-4825-8fca-c09f523e87ba\n:END:\n#+title: Bruce Wayne\n")))
|
||||||
|
|
||||||
(provide 'test-org-roam-node)
|
(provide 'test-org-roam-node)
|
||||||
|
|
||||||
|
@ -36,17 +36,17 @@
|
|||||||
(delete-file org-roam-db-location))
|
(delete-file org-roam-db-location))
|
||||||
|
|
||||||
(it "gets files correctly"
|
(it "gets files correctly"
|
||||||
(expect (length (org-roam-list-files)) :to-equal 7))
|
(expect (length (org-roam-list-files)) :to-equal 8))
|
||||||
|
|
||||||
(it "respects org-roam-file-extensions"
|
(it "respects org-roam-file-extensions"
|
||||||
(setq org-roam-file-extensions '("md"))
|
(setq org-roam-file-extensions '("md"))
|
||||||
(expect (length (org-roam-list-files)) :to-equal 1)
|
(expect (length (org-roam-list-files)) :to-equal 1)
|
||||||
(setq org-roam-file-extensions '("org" "md"))
|
(setq org-roam-file-extensions '("org" "md"))
|
||||||
(expect (length (org-roam-list-files)) :to-equal 8))
|
(expect (length (org-roam-list-files)) :to-equal 9))
|
||||||
|
|
||||||
(it "respects org-roam-file-exclude-regexp"
|
(it "respects org-roam-file-exclude-regexp"
|
||||||
(setq org-roam-file-exclude-regexp (regexp-quote "foo.org"))
|
(setq org-roam-file-exclude-regexp (regexp-quote "foo.org"))
|
||||||
(expect (length (org-roam-list-files)) :to-equal 6)))
|
(expect (length (org-roam-list-files)) :to-equal 7)))
|
||||||
|
|
||||||
(describe "org-roam-db-sync"
|
(describe "org-roam-db-sync"
|
||||||
(before-all
|
(before-all
|
||||||
@ -63,12 +63,12 @@
|
|||||||
(it "has the correct number of files"
|
(it "has the correct number of files"
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from files]))
|
(expect (caar (org-roam-db-query [:select (funcall count) :from files]))
|
||||||
:to-equal
|
:to-equal
|
||||||
7))
|
8))
|
||||||
|
|
||||||
(it "has the correct number of nodes"
|
(it "has the correct number of nodes"
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from nodes]))
|
(expect (caar (org-roam-db-query [:select (funcall count) :from nodes]))
|
||||||
:to-equal
|
:to-equal
|
||||||
8))
|
9))
|
||||||
|
|
||||||
(it "has the correct number of links"
|
(it "has the correct number of links"
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links]))
|
(expect (caar (org-roam-db-query [:select (funcall count) :from links]))
|
||||||
@ -85,8 +85,9 @@
|
|||||||
"0fa5bb3e-3d8c-4966-8bc9-78d32e505d69"
|
"0fa5bb3e-3d8c-4966-8bc9-78d32e505d69"
|
||||||
"5fb4fdc5-b6d2-4f75-8d54-e60053e467ec"
|
"5fb4fdc5-b6d2-4f75-8d54-e60053e467ec"
|
||||||
"77a90980-1994-464e-901f-7e3d3df07fd3"
|
"77a90980-1994-464e-901f-7e3d3df07fd3"
|
||||||
"57FF3CE7-5BDA-4825-8FCA-C09F523E87BA"
|
"57ff3ce7-5bda-4825-8fca-c09f523e87ba"
|
||||||
"998b2341-b7fe-434d-848c-5282c0727870")))
|
"998b2341-b7fe-434d-848c-5282c0727870"
|
||||||
|
"97bf31cf-dfee-45d8-87a5-2ae0dabc4734")))
|
||||||
|
|
||||||
(it "reads ref in quotes correctly"
|
(it "reads ref in quotes correctly"
|
||||||
(expect (mapcar #'car (org-roam-db-query [:select [ref] :from refs]))
|
(expect (mapcar #'car (org-roam-db-query [:select [ref] :from refs]))
|
||||||
|
Reference in New Issue
Block a user