Attached

On Sat, Jun 25, 2022 at 9:48 PM Ihor Radchenko <yanta...@gmail.com> wrote:

> Allen Li <darkfel...@felesatra.moe> writes:
>
> >> Would you also be interested to write a test checking org-todo ARGS?
> >>
> >
> > Attached
>
> Thanks! However, it is unclear what this test is checking for.
>
> > +(ert-deftest test-org/org-todo-prefix ()
> > +  "Test `org-todo' prefix arg behavior."
> > +  ;; -1 prefix arg should cancel repeater and mark DONE.
> > +  (should-not
> > +   (string-prefix-p
> > +    "* TODO H"
> > +    (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
> > +      (org-test-with-temp-text "* TODO H\n<2012-03-29 Thu +2y>"
> > +                            (org-todo -1)
> > +                            (buffer-string)))))
>
> This test does not check if the task is actually marked DONE and also
> does not check if the repeater is canceled.
>
> Best,
> Ihor
>
>
From 42156ba1e8b3c589394212ef423f99e122544c5f Mon Sep 17 00:00:00 2001
From: Allen Li <darkfel...@felesatra.moe>
Date: Sat, 25 Jun 2022 21:27:20 -0700
Subject: [PATCH] test-org: Add test for org-todo prefix behavior

* testing/lisp/test-org.el (test-org/org-todo-prefix): Add test.
---
 testing/lisp/test-org.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 121f9efd5..d686c0e3b 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -7753,6 +7753,25 @@ CLOSED: %s
           (org-add-log-note))
         (buffer-string))))))
 
+(ert-deftest test-org/org-todo-prefix ()
+  "Test `org-todo' prefix arg behavior."
+  ;; -1 prefix arg should cancel repeater and mark DONE.
+  (should
+   (string-match-p
+    "DONE H\\(.*\n\\)*<2012-03-29 Thu \\+0y>"
+    (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text "* TODO H\n<2012-03-29 Thu +2y>"
+	(org-todo -1)
+	(buffer-string)))))
+  ;; - prefix arg should cancel repeater and mark DONE.
+  (should
+   (string-match-p
+    "DONE H\\(.*\n\\)*<2012-03-29 Thu \\+0y>"
+    (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text "* TODO H\n<2012-03-29 Thu +2y>"
+	(org-todo '-)
+	(buffer-string))))))
+
 
 ;;; Timestamps API
 
-- 
2.36.1

Reply via email to