From d7e72b9f0189b98d7ae59f0a56d54ffe70583956 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Tue, 2 Jan 2024 14:25:07 -0500 Subject: [PATCH] Testing: Add tests for 'org-agenda-skip-scheduled-if-deadline-is-shown' * testing/lisp/test-org-agenda.el (test-org-agenda/org-agenda-skip-scheduled-if-deadline-is-shown): New test. --- testing/lisp/test-org-agenda.el | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index 409d44192..6618fabc5 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -651,6 +651,51 @@ functions." (should (= arg-f-call-cnt 1)) (should (equal f-called-args '(1 2 3)))))) +(ert-deftest test-org-agenda/org-agenda-skip-scheduled-if-deadline-is-shown () + "Test values for `org-agenda-skip-scheduled-if-deadline-is-shown'." + (cl-assert (not org-agenda-sticky) nil "precondition violation") + (cl-assert (not (org-test-agenda--agenda-buffers)) + nil "precondition violation") + (dolist (test-time '("2017-03-06" "2017-03-10")) + (let ((org-agenda-custom-commands + '(("f" "no fluff" agenda "" + ((org-agenda-overriding-header "") + (org-agenda-todo-keyword-format "") + (org-agenda-prefix-format "%s") + (org-agenda-format-date "%d") + (org-agenda-show-all-dates nil))))) + (org-deadline-warning-days 0) + (todayp (string= test-time "2017-03-10"))) + (dolist (org-agenda-skip-scheduled-if-deadline-is-shown (list nil t 'not-today 'repeated-after-deadline)) + (org-test-at-time test-time + (org-test-agenda-with-agenda + " +* TODO task +SCHEDULED: <2017-03-06 Mon +2d> DEADLINE: <2017-03-10> +" + (should + (string-equal + (concat "06\n" + "Scheduled: task\n" + (if todayp ; We don't show repeats scheduled in the past + "" + "08\nScheduled: task\n") + "10\n" + (if (and org-agenda-skip-scheduled-if-deadline-is-shown + (not (and (not todayp) (eq org-agenda-skip-scheduled-if-deadline-is-shown 'not-today))) + (not (eq org-agenda-skip-scheduled-if-deadline-is-shown 'repeated-after-deadline))) + "" + (if todayp + "Sched. 4x: task\n" + "Scheduled: task\n")) + "Deadline: task\n" + (unless (eq org-agenda-skip-scheduled-if-deadline-is-shown 'repeated-after-deadline) + "12\nScheduled: task\n")) + (progn + (org-agenda nil "f") + (substring-no-properties (buffer-string))))) + (org-test-agenda--kill-all-agendas))))))) + (provide 'test-org-agenda) -- 2.41.0