lang/org: fix insert-item tests; refactor +org/insert-item

This commit is contained in:
Henrik Lissner 2018-02-17 22:41:58 -05:00
parent cf4420e903
commit aafa45e271
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 30 additions and 13 deletions

View file

@ -1,6 +1,8 @@
;; -*- no-byte-compile: t; -*-
;;; lang/org/test/autoload-org.el
(require! :lang org)
(defmacro should-org-buffer!! (source expected &rest body)
`(should-buffer!! ,source ,expected
(org-mode)
@ -40,3 +42,21 @@ newline."
"+ {|}"
"+ Next item")
(+org/insert-item 'below)))
(def-test! insert-item-numbered-list
"Should append/prepend new second-level (and higher) headers without an extra
newline."
(should-org-buffer!! ("1. {0}List item") ("1. List item\n2. {|}")
(+org/insert-item 'below))
(should-org-buffer!! ("1. {0}List item"
"2. Sub item")
("1. List item"
"2. {|}"
"3. Sub item")
(+org/insert-item 'below))
(should-org-buffer!! ("1. {0}List item"
"2. Next item")
("1. {|}"
"2. List item"
"3. Next item")
(+org/insert-item 'above)))