emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Testing: Add tests for 'org-agenda-skip-if'
Date: Sat, 15 Jul 2023 18:06:37 -0400	[thread overview]
Message-ID: <DM5PR03MB3163438B9ADBD32BB7C91ADEC535A@DM5PR03MB3163.namprd03.prod.outlook.com> (raw)

* 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



             reply	other threads:[~2023-07-15 22:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15 22:06 Morgan Smith [this message]
2023-07-16 10:11 ` [PATCH] Testing: Add tests for 'org-agenda-skip-if' Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM5PR03MB3163438B9ADBD32BB7C91ADEC535A@DM5PR03MB3163.namprd03.prod.outlook.com \
    --to=morgan.j.smith@outlook.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).