branch: externals/org commit 58c48194f5ef69c952a44ead5ea6de722527646e Author: Jack Kamm <jackk...@gmail.com> Commit: Jack Kamm <jackk...@gmail.com>
org-datetree: Add unit tests for incorrect sorting * testing/lisp/test-org-datetree.el (test-org-datetree/find-date-create): Add test that a subtree is inserted in the correct location, even if there exists another subtree that looks like a datetree. (test-org-datetree/find-iso-week-create): Add test that days within a week spanning 2 years are sorted correctly. --- testing/lisp/test-org-datetree.el | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/testing/lisp/test-org-datetree.el b/testing/lisp/test-org-datetree.el index bd06462f2c..620a916dfb 100644 --- a/testing/lisp/test-org-datetree.el +++ b/testing/lisp/test-org-datetree.el @@ -108,6 +108,30 @@ (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012))) (org-trim (buffer-string))))) + ;; Insert at correct location, even if some other heading has a + ;; subtree that looks like a datetree + (should + (string-match + "\\`\\* Dummy heading + +\\*\\* 2012 + +\\* 2012 + +\\*\\* 2012-03 March + +\\*\\*\\* 2012-03-29 .*\\'" + (org-test-with-temp-text "\ +* Dummy heading + +** 2012 + +* 2012 + +** 2012-03 March" + (let ((org-datetree-add-timestamp nil)) + (org-datetree-find-date-create '(3 29 2012))) + (org-trim (buffer-string))))) ;; Always leave point at beginning of day entry. (should (string-match @@ -188,6 +212,21 @@ (org-datetree-find-iso-week-create '(9 1 2015)) (org-datetree-find-iso-week-create '(12 31 2014))) (org-trim (buffer-string))))) + ;; Sort new entry in correct order within its week when + ;; iso-week-year is not calendar year + (should + (string-match + "\\`\\* 2015 + +\\*\\* 2015-W01 + +\\*\\*\\* 2014-12-31 .* +\\*\\*\\* 2015-01-01 .*" + (org-test-with-temp-text "* 2015" + (let ((org-datetree-add-timestamp nil)) + (org-datetree-find-iso-week-create '(1 1 2015)) + (org-datetree-find-iso-week-create '(12 31 2014))) + (org-trim (buffer-string))))) ;; When `org-datetree-add-timestamp' is non-nil, insert a timestamp ;; in entry. When set to `inactive', insert an inactive one. (should