Add test checking org-log-done specs

* testing/lisp/test-org.el (test-org/org-log-done): New test
This commit is contained in:
Ihor Radchenko 2021-07-11 13:38:07 +08:00 committed by Bastien
parent 46511212e9
commit d3d80c5948
1 changed files with 126 additions and 0 deletions

View File

@ -7433,6 +7433,132 @@ SCHEDULED: <2021-06-15 Tue +1d>"
(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
<point>* 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
<point>* 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