From e992a2846b2692c63e25536610258ee0b6b2056e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 4 Oct 2016 11:35:57 +0200 Subject: [PATCH] Add more tests for `org-insert-heading' * testing/lisp/test-org.el (test-org/insert-heading): Add tests. --- testing/lisp/test-org.el | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index cddc33d8f..f697b4286 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1169,6 +1169,45 @@ (let ((org-M-RET-may-split-line '((default . nil)))) (org-insert-heading)) (buffer-string)))) + ;; At the beginning of a headline, create one above. + (should + (equal "* \n* H" + (org-test-with-temp-text "* H" + (org-insert-heading) + (buffer-string)))) + ;; In the middle of a headline, split it if allowed. + (should + (equal "* H\n* 1" + (org-test-with-temp-text "* H1" + (let ((org-M-RET-may-split-line '((headline . t)))) + (org-insert-heading)) + (buffer-string)))) + (should + (equal "* H1\n* " + (org-test-with-temp-text "* H1" + (let ((org-M-RET-may-split-line '((headline . nil)))) + (org-insert-heading)) + (buffer-string)))) + ;; However, splitting cannot happen on TODO keywords, priorities or + ;; tags. + (should + (equal "* TODO H1\n* " + (org-test-with-temp-text "* TODO H1" + (let ((org-M-RET-may-split-line '((headline . t)))) + (org-insert-heading)) + (buffer-string)))) + (should + (equal "* [#A] H1\n* " + (org-test-with-temp-text "* [#A] H1" + (let ((org-M-RET-may-split-line '((headline . t)))) + (org-insert-heading)) + (buffer-string)))) + (should + (equal "* H1 :tag:\n* " + (org-test-with-temp-text "* H1 :tag:" + (let ((org-M-RET-may-split-line '((headline . t)))) + (org-insert-heading)) + (buffer-string)))) ;; When on a list, insert an item instead, unless called with an ;; universal argument or if list is invisible. In this case, create ;; a new headline after contents. @@ -1203,6 +1242,23 @@ (let ((org-insert-heading-respect-content nil)) (org-insert-heading)) (list (get-char-property (line-beginning-position 0) 'invisible) (get-char-property (line-end-position 2) 'invisible)))))) + ;; When called with one universal argument, insert a new headline at + ;; the end of the current subtree, independently on the position of + ;; point. + (should + (equal + "* H1\n** H2\n* " + (org-test-with-temp-text "* H1\n** H2" + (let ((org-insert-heading-respect-content nil)) + (org-insert-heading '(4))) + (buffer-string)))) + (should + (equal + "* H1\n** H2\n* " + (org-test-with-temp-text "* H1\n** H2" + (let ((org-insert-heading-respect-content nil)) + (org-insert-heading '(4))) + (buffer-string)))) ;; When called with two universal arguments, insert a new headline ;; at the end of the grandparent subtree. (should -- 2.11.4.GIT