aboutsummaryrefslogtreecommitdiff
path: root/tests/test-org-roam-config-format.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-20 23:50:59 -0500
committerCraig Jennings <c@cjennings.net>2026-07-20 23:50:59 -0500
commit0fa283a3a828bd99260792a4fffd772b2cec5bc0 (patch)
tree1d3ec717adaf98569e65aec8f08a2d5ee6a8e541 /tests/test-org-roam-config-format.el
parente83a055602ea2ad6cf8de5909bcbd8e44f2b5c22 (diff)
downloaddotemacs-0fa283a3a828bd99260792a4fffd772b2cec5bc0.tar.gz
dotemacs-0fa283a3a828bd99260792a4fffd772b2cec5bc0.zip
test: make the 31st-recurrence and immediate-insert tests env-stable
The calendar test's range ended at midnight Dec 31, excluding that day's occurrence, and the org-roam test asserted special-variable-p, which answers differently in the package-loaded hook env versus bare batch (a bare defvar is a file-local declaration). The recurrence test now ends the range past the year and the insert test asserts the binding behaviorally.
Diffstat (limited to 'tests/test-org-roam-config-format.el')
-rw-r--r--tests/test-org-roam-config-format.el22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/test-org-roam-config-format.el b/tests/test-org-roam-config-format.el
index caafe563..16370ca1 100644
--- a/tests/test-org-roam-config-format.el
+++ b/tests/test-org-roam-config-format.el
@@ -147,13 +147,21 @@ Returns the formatted file content."
(let ((result (test-format "Title" "id" "* Content")))
(should (string-match-p "#\\+FILETAGS: Topic\n\n\\* Content" result))))
-(ert-deftest test-org-roam-config-capture-templates-declared-special ()
- "Normal: org-roam-capture-templates is declared special in the module.
-cj/org-roam-node-insert-immediate let-binds it; without the defvar the
-byte-compiled let is a dead lexical binding and :immediate-finish never
-reaches org-roam-node-insert -- the \"immediate\" insert opens a capture
-buffer."
- (should (special-variable-p 'org-roam-capture-templates)))
+(defvar org-roam-capture-templates)
+
+(ert-deftest test-org-roam-config-immediate-insert-binding-is-dynamic ()
+ "Normal: the immediate-insert template binding reaches the insert call.
+Without the module's defvar, the byte-compiled let is a dead lexical
+binding: org-roam-node-insert would see the untouched global templates
+and :immediate-finish never applies -- the \"immediate\" insert opens a
+capture buffer. Asserted behaviorally (not via special-variable-p,
+whose answer differs between the package-loaded and bare batch envs)."
+ (let ((org-roam-capture-templates '(("d" "default")))
+ seen)
+ (cl-letf (((symbol-function 'org-roam-node-insert)
+ (lambda (&rest _) (setq seen org-roam-capture-templates))))
+ (cj/org-roam-node-insert-immediate nil))
+ (should (equal seen '(("d" "default" :immediate-finish t))))))
(provide 'test-org-roam-config-format)
;;; test-org-roam-config-format.el ends here