summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-10-04 11:35:57 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-10-04 11:35:57 +0200
commite992a2846b2692c63e25536610258ee0b6b2056e (patch)
tree5a7beff796f79d146bb828eac51383005a3afcc4
parent2b03e945a19701194e510791a96006c5eee9edc6 (diff)
downloadorg-mode-e992a2846b2692c63e25536610258ee0b6b2056e.tar.gz
Add more tests for `org-insert-heading'
* testing/lisp/test-org.el (test-org/insert-heading): Add tests.
-rw-r--r--testing/lisp/test-org.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index cddc33d..f697b42 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 "* H<point>1"
+ (let ((org-M-RET-may-split-line '((headline . t))))
+ (org-insert-heading))
+ (buffer-string))))
+ (should
+ (equal "* H1\n* "
+ (org-test-with-temp-text "* H<point>1"
+ (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 "* TO<point>DO 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 "* [#<point>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 :ta<point>g:"
+ (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 "* H<point>1\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