emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] scratch/org-edna 7978874 24/72: Added tests for ids and match fin


From: Ian Dunn
Subject: [elpa] scratch/org-edna 7978874 24/72: Added tests for ids and match finders
Date: Sun, 21 May 2017 21:11:22 -0400 (EDT)

branch: scratch/org-edna
commit 79788745d429221a791280eebf75e4a49050d26f
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>

    Added tests for ids and match finders
---
 org-edna-tests.el | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/org-edna-tests.el b/org-edna-tests.el
index 33665a4..d5f629c 100644
--- a/org-edna-tests.el
+++ b/org-edna-tests.el
@@ -59,6 +59,55 @@
       (should (not modifier))
       (should (= pos (length input-string))))))
 
+(defconst org-edna-test-dir
+  (expand-file-name (file-name-directory (or load-file-name 
buffer-file-name))))
+
+(defconst org-edna-test-file
+  (expand-file-name "org-edna-tests.org" org-edna-test-dir))
+
+
+;; Finders
+
+(defsubst org-edna-heading (pom)
+  (org-with-point-at pom
+    (org-get-heading t t t t)))
+
+(ert-deftest org-edna-finder/match-single-arg ()
+  (let* ((org-agenda-files `(,org-edna-test-file))
+         (targets (org-edna-finder/match "test&1")))
+    (should (= (length targets) 2))
+    (should (string-equal (org-edna-heading (nth 0 targets)) "Tagged Heading 
1"))
+    (should (string-equal (org-edna-heading (nth 1 targets)) "Tagged Heading 
2"))))
+
+(ert-deftest org-edna-finder/ids-single ()
+  (let* ((org-agenda-files `(,org-edna-test-file))
+         (test-id "caccd0a6-d400-410a-9018-b0635b07a37e")
+         (targets (org-edna-finder/ids test-id)))
+    (should (= (length targets) 1))
+    (should (string-equal (org-edna-heading (nth 0 targets)) "Blocking Test"))
+    (should (string-equal (org-entry-get (nth 0 targets) "ID") test-id))))
+
+(ert-deftest org-edna-finder/ids-multiple ()
+  (let* ((org-agenda-files `(,org-edna-test-file))
+         (test-ids '("0d491588-7da3-43c5-b51a-87fbd34f79f7"
+                     "b010cbad-60dc-46ef-a164-eb155e62cbb2"))
+         (targets (apply 'org-edna-finder/ids test-ids)))
+    (should (= (length targets) 2))
+    (should (string-equal (org-edna-heading (nth 0 targets)) "ID Heading 1"))
+    (should (string-equal (org-entry-get (nth 0 targets) "ID") (nth 0 
test-ids)))
+    (should (string-equal (org-edna-heading (nth 1 targets)) "ID Heading 2"))
+    (should (string-equal (org-entry-get (nth 1 targets) "ID") (nth 1 
test-ids)))))
+
+(ert-deftest org-edna-finder/match-blocker ()
+  (let* ((org-agenda-files `(,org-edna-test-file))
+         (heading (org-id-find "caccd0a6-d400-410a-9018-b0635b07a37e" t))
+         (blocker (org-entry-get heading "BLOCKER")))
+    (should (string-equal "match(test&1)" blocker))
+    (org-with-point-at heading
+      (org-edna-process-form blocker 'condition))
+    (should (string-equal (substring-no-properties org-block-entry-blocking)
+                          "TODO Tagged Heading 1 :1:test:"))))
+
 (provide 'org-edna-tests)
 
 ;;; org-edna-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]