From 2a58a82520de57142c6a397d811290f19789635f Mon Sep 17 00:00:00 2001 Message-Id: <2a58a82520de57142c6a397d811290f19789635f.1625983309.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sun, 11 Jul 2021 13:38:07 +0800 Subject: [PATCH] Add test checking org-log-done specs * testing/lisp/test-org.el (test-org/org-log-done): New test --- testing/lisp/test-org.el | 126 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index c2267c32d..6922cbb4f 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -7418,6 +7418,132 @@ (ert-deftest test-org/auto-repeat-maybe () (org-add-log-note)) (buffer-string)))))) +(ert-deftest test-org/org-log-done () + "Test `org-log-done' specifications." + ;; nil value. + (should + (string= + "* DONE task" + (let ((org-log-done nil) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "* TODO task" + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string))))) + ;; `time' value. + (should + (string= + (format + "* DONE task +CLOSED: %s" + (org-test-with-temp-text "" + (org-insert-time-stamp (current-time) t t) + (buffer-string))) + (let ((org-log-done 'time) + (org-log-done-with-time t) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "* TODO task" + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string))))) + (should + (string= + (format + "* DONE task +CLOSED: %s" + (org-test-with-temp-text "" + (org-insert-time-stamp (current-time) nil t) + (buffer-string))) + (let ((org-log-done 'time) + (org-log-done-with-time nil) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "* TODO task" + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string))))) + ;; TODO: Test `note' value. + ;; Test startup overrides. + (should + (string= + "#+STARTUP: nologdone +* DONE task" + (let ((org-log-done 'time) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "#+STARTUP: nologdone +* TODO task" + (org-set-regexps-and-options) + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string))))) + (should + (string= + (format + "#+STARTUP: logdone +* DONE task +CLOSED: %s" + (org-test-with-temp-text "" + (org-insert-time-stamp (current-time) t t) + (buffer-string))) + (let ((org-log-done nil) + (org-log-done-with-time t) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "#+STARTUP: logdone +* TODO task" + (org-set-regexps-and-options) + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string))))) + ;; Test local property overrides. + (should + (string= + "* DONE task +:PROPERTIES: +:LOGGING: nil +:END:" + (let ((org-log-done 'time) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "* TODO task +:PROPERTIES: +:LOGGING: nil +:END:" + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string))))) + (should + (string= + (format + "* DONE task +CLOSED: %s +:PROPERTIES: +:LOGGING: logdone +:END:" + (org-test-with-temp-text "" + (org-insert-time-stamp (current-time) t t) + (buffer-string))) + (let ((org-log-done nil) + (org-log-done-with-time t) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "* TODO task +:PROPERTIES: +:LOGGING: logdone +:END:" + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string)))))) ;;; Timestamps API -- 2.31.1