emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Testing: Add tests for 'org-agenda-skip-if'
@ 2023-07-15 22:06 Morgan Smith
  2023-07-16 10:11 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Morgan Smith @ 2023-07-15 22:06 UTC (permalink / raw)
  To: emacs-orgmode

* testing/lisp/test-org-agenda.el (test-org-agenda/skip-if): New test.
(test-org-agenda/non-scheduled-re-matces): Fix typo by changing name
to 'test-org-agenda/non-scheduled-re-matches'.
---
 testing/lisp/test-org-agenda.el | 62 ++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index 22e3106ec..c4bd4f0a7 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -99,7 +99,7 @@
 	      (looking-at " *agenda-file:Scheduled: *test agenda"))))
     (org-test-agenda--kill-all-agendas)))
 
-(ert-deftest test-org-agenda/non-scheduled-re-matces ()
+(ert-deftest test-org-agenda/non-scheduled-re-matches ()
   "Make sure that scheduled-looking elements do not appear in agenda.
 See https://list.orgmode.org/20220101200103.GB29829@itccanarias.org/T/#t."
   (cl-assert (not org-agenda-sticky) nil "precondition violation")
@@ -269,6 +269,66 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com"
       (should (not (invisible-p (1- (search-forward "TODO Foo")))))))
   (org-toggle-sticky-agenda))
 
+(ert-deftest test-org-agenda/skip-if ()
+  "Test `org-agenda-skip-if'."
+  (dolist (options '((scheduled) (notscheduled)
+                     (deadline) (notdeadline)
+                     (timestamp) (nottimestamp)
+                     (regexp "hello") (notregexp "hello")
+                     ;; TODO: Test for specific TODO keywords
+                     (todo ("*")) (nottodo ("*"))))
+    (should
+     (equal
+      (if (memq (car options) '(notscheduled notdeadline nottimestamp regexp nottodo))
+          8
+        nil)
+      (org-test-with-temp-text
+          "* hello"
+        (org-agenda-skip-if nil options))))
+    (should
+     (equal
+      (if (memq (car options) '(scheduled notdeadline timestamp regexp nottodo))
+          36
+        nil)
+      (org-test-with-temp-text
+          "* hello
+SCHEDULED: <2023-07-15 Sat>"
+        (org-agenda-skip-if nil options))))
+    (should
+     (equal
+      (if (memq (car options) '(notscheduled deadline timestamp regexp nottodo))
+          35
+        nil)
+      (org-test-with-temp-text
+          "* hello
+DEADLINE: <2023-07-15 Sat>"
+        (org-agenda-skip-if nil options))))
+    (should
+     (equal
+      (if (memq (car options) '(notscheduled notdeadline timestamp regexp nottodo))
+          25
+        nil)
+      (org-test-with-temp-text
+          "* hello
+<2023-07-15 Sat>"
+        (org-agenda-skip-if nil options))))
+    (should
+     (equal
+      (if (memq (car options) '(notscheduled notdeadline nottimestamp notregexp nottodo))
+          10
+        nil)
+      (org-test-with-temp-text
+          "* goodbye"
+        (org-agenda-skip-if nil options))))
+    (should
+     (equal
+      (if (memq (car options) '(notscheduled notdeadline nottimestamp notregexp todo))
+          26
+        nil)
+      (org-test-with-temp-text
+          "* TODO write better tests"
+        (org-agenda-skip-if nil options))))))
+
 (ert-deftest test-org-agenda/goto-date ()
   "Test `org-agenda-goto-date'."
   (unwind-protect
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-16 10:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-15 22:06 [PATCH] Testing: Add tests for 'org-agenda-skip-if' Morgan Smith
2023-07-16 10:11 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).