Fix `org-toggle-tag'
[org-mode/org-tableheadings.git] / testing / lisp / test-org-list.el
blob93c6680ba12c98af0114292d86081626be6e55bf
1 ;;; test-org-list.el --- Tests for org-list.el
3 ;; Copyright (C) 2012, 2013, 2014, 2018 Nicolas Goaziou
5 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ;;; Code:
22 (ert-deftest test-org-list/list-ending ()
23 "Test if lists end at the right place."
24 ;; With two blank lines.
25 (org-test-with-temp-text "- item\n\n\n Text"
26 (goto-line 4)
27 (should-not (org-in-item-p)))
28 ;; With text less indented than top items.
29 (org-test-with-temp-text "- item\nText"
30 (goto-line 2)
31 (should-not (org-in-item-p)))
32 ;; Though, blank lines and text indentation is ignored in blocks.
33 (org-test-with-temp-text
34 "- item\n #+begin_quote\n\n\nText at column 0\n #+end_quote\n Text"
35 (goto-line 7)
36 (should (org-in-item-p))))
38 (ert-deftest test-org-list/list-navigation ()
39 "Test list navigation specifications."
40 (org-test-with-temp-text "
41 - item A
42 - item B
45 - item 1
46 - item 1.1
47 - item 1.2
48 - item 1.3
49 - item 2
52 - item X
53 - item Y"
54 (let ((org-list-use-circular-motion nil))
55 ;; 1. Test `org-next-item'.
57 ;; 1.1. Should return an error if at last item in
58 ;; a list/sub-list, unless `org-list-use-circular-motion'
59 ;; is non-nil.
60 (goto-line 9)
61 (should-error (org-next-item))
62 (let ((org-list-use-circular-motion t))
63 (should (progn (org-next-item) t)))
64 (goto-line 14)
65 (should-error (org-next-item))
66 (let ((org-list-use-circular-motion t))
67 (should (progn (org-next-item) t)))
68 ;; 1.2. Should jump over sub-lists.
69 (goto-line 6)
70 (org-next-item)
71 (should (looking-at "- item 2"))
72 ;; 1.3. Shouldn't move to another list.
73 (goto-line 3)
74 (should-error (org-next-item))
75 (should-not (looking-at "- item 1"))
76 ;; 1.4. Should move to the list/sub-list first item when
77 ;; `org-list-use-circular-motion' is non-nil.
78 (let ((org-list-use-circular-motion t))
79 (goto-line 10)
80 (org-next-item)
81 (should (looking-at "- item 1"))
82 (goto-line 9)
83 (org-next-item)
84 (should (looking-at " - item 1.1")))
85 ;; 2. Test `org-previous-item'.
87 ;; 2.1. Should return an error if at first item in
88 ;; a list/sub-list, unless `org-list-use-circular-motion is
89 ;; non-nil.
90 (goto-line 7)
91 (should-error (org-previous-item))
92 (let ((org-list-use-circular-motion t))
93 (should (progn (org-previous-item) t)))
94 (goto-line 13)
95 (should-error (org-previous-item))
96 (let ((org-list-use-circular-motion t))
97 (should (progn (org-previous-item) t)))
98 ;; 2.2. Should ignore sub-lists.
99 (goto-line 10)
100 (org-previous-item)
101 (should (looking-at "- item 1"))
102 ;; 2.3. Shouldn't move to another list.
103 (goto-line 6)
104 (should-error (org-previous-item))
105 (should-not (looking-at "- item B"))
106 ;; 2.4. Should move to the list/sub-list last item when
107 ;; `org-list-use-circular-motion' is non-nil.
108 (let ((org-list-use-circular-motion t))
109 (goto-line 6)
110 (org-previous-item)
111 (should (looking-at "- item 2"))
112 (goto-line 7)
113 (org-previous-item)
114 (should (looking-at " - item 1.3"))))))
116 (ert-deftest test-org-list/cycle-bullet ()
117 "Test `org-cycle-list-bullet' specifications."
118 ;; Error when not at an item.
119 (should-error
120 (org-test-with-temp-text "Paragraph"
121 (org-cycle-list-bullet)))
122 ;; Cycle through "-", "+", "*", "1.", "1)".
123 (org-test-with-temp-text " - item"
124 (org-cycle-list-bullet)
125 (should (looking-at "[ \t]+\\+"))
126 (org-cycle-list-bullet)
127 (should (looking-at "[ \t]+\\*"))
128 (let ((org-plain-list-ordered-item-terminator t))
129 (org-cycle-list-bullet))
130 (should (looking-at "[ \t]+1\\."))
131 (let ((org-plain-list-ordered-item-terminator t))
132 (org-cycle-list-bullet))
133 (should (looking-at "[ \t]+1)")))
134 ;; Argument is a valid bullet: cycle to that bullet directly.
135 (should
136 (equal "1. item"
137 (org-test-with-temp-text "- item"
138 (let ((org-plain-list-ordered-item-terminator t))
139 (org-cycle-list-bullet "1.")
140 (buffer-string)))))
141 ;; Argument is an integer N: cycle to the Nth allowed bullet.
142 (should
143 (equal "+ item"
144 (org-test-with-temp-text "1. item"
145 (let ((org-plain-list-ordered-item-terminator t))
146 (org-cycle-list-bullet 1)
147 (buffer-string)))))
148 ;; Argument is `previous': cycle backwards.
149 (should
150 (equal "- item"
151 (org-test-with-temp-text "+ item"
152 (let ((org-plain-list-ordered-item-terminator t))
153 (org-cycle-list-bullet 'previous)
154 (buffer-string)))))
155 ;; Do not cycle to "*" bullets when item is at column 0.
156 (should
157 (equal "1. item"
158 (org-test-with-temp-text "+ item"
159 (let ((org-plain-list-ordered-item-terminator t))
160 (org-cycle-list-bullet)
161 (buffer-string)))))
162 ;; Do not cycle to numbered bullets in a description list.
163 (should-not
164 (equal "1. tag :: item"
165 (org-test-with-temp-text "+ tag :: item"
166 (let ((org-plain-list-ordered-item-terminator t))
167 (org-cycle-list-bullet)
168 (buffer-string)))))
169 ;; Do not cycle to ordered item terminators if they are not allowed
170 ;; in `org-plain-list-ordered-item-terminator'.
171 (should
172 (equal " 1) item"
173 (org-test-with-temp-text " * item"
174 (let ((org-plain-list-ordered-item-terminator 41))
175 (org-cycle-list-bullet)
176 (buffer-string)))))
177 ;; When `org-list-allow-alphabetical' is non-nil, cycle to alpha bullets.
178 (should
179 (equal "a. item"
180 (org-test-with-temp-text "1) item"
181 (let ((org-plain-list-ordered-item-terminator t)
182 (org-list-allow-alphabetical t))
183 (org-cycle-list-bullet)
184 (buffer-string)))))
185 ;; Do not cycle to alpha bullets when list has more than 26
186 ;; elements.
187 (should-not
188 (equal "a. item 1"
189 (org-test-with-temp-text "1) item 1
190 2) item 2
191 3) item 3
192 4) item 4
193 5) item 5
194 6) item 6
195 7) item 7
196 8) item 8
197 9) item 9
198 10) item 10
199 11) item 11
200 12) item 12
201 13) item 13
202 14) item 14
203 15) item 15
204 16) item 16
205 17) item 17
206 18) item 18
207 19) item 19
208 20) item 20
209 21) item 21
210 22) item 22
211 23) item 23
212 24) item 24
213 25) item 25
214 26) item 26
215 27) item 27"
216 (let ((org-plain-list-ordered-item-terminator t)
217 (org-list-allow-alphabetical t))
218 (org-cycle-list-bullet)
219 (buffer-substring (point) (line-end-position)))))))
221 (ert-deftest test-org-list/indent-item ()
222 "Test `org-indent-item' specifications."
223 ;; 1. Error when not at an item.
224 (org-test-with-temp-text "Paragraph."
225 (should-error (org-indent-item)))
226 ;; 2. Error when trying to move first item of a list.
227 (org-test-with-temp-text "
228 - Item 1
229 - Item 2"
230 (forward-line)
231 (should-error (org-indent-item)))
232 ;; 3. Indent a single item, not its children.
233 (org-test-with-temp-text "
234 - Item 1
235 - Item 2
236 - Item 2.1"
237 (search-forward "- Item 2")
238 (let (org-list-demote-modify-bullet) (org-indent-item))
239 (should (equal (buffer-string)
241 - Item 1
242 - Item 2
243 - Item 2.1")))
244 ;; 4. Follow `org-list-demote-modify-bullet' specifications.
246 ;; 4.1. With unordered lists.
247 (org-test-with-temp-text "
248 - Item 1
249 - Item 2"
250 (search-forward "- Item 2")
251 (let ((org-list-demote-modify-bullet '(("-" . "+")))) (org-indent-item))
252 (should (equal (buffer-string)
254 - Item 1
255 + Item 2")))
256 ;; 4.2. and ordered lists.
257 (org-test-with-temp-text "
258 1. Item 1
259 2. Item 2"
260 (search-forward "2. Item 2")
261 (let ((org-plain-list-ordered-item-terminator t)
262 (org-list-demote-modify-bullet '(("1." . "+"))))
263 (org-indent-item))
264 (should (equal (buffer-string)
266 1. Item 1
267 + Item 2")))
268 ;; 5. When a region is selected, indent every item within.
269 (org-test-with-temp-text "
270 - Item 1
271 - Item 2
272 - Item 3
274 (search-forward "- Item 2")
275 (beginning-of-line)
276 (transient-mark-mode 1)
277 (push-mark (point) t t)
278 (goto-char (point-max))
279 (let (org-list-demote-modify-bullet) (org-indent-item))
280 (should (equal (buffer-string)
282 - Item 1
283 - Item 2
284 - Item 3
285 "))))
287 (ert-deftest test-org-list/indent-item-tree ()
288 "Test `org-indent-item-tree' specifications."
289 ;; 1. Error when not at an item.
290 (org-test-with-temp-text "Paragraph."
291 (should-error (org-indent-item-tree)))
292 ;; 2. Indent item along with its children.
293 (org-test-with-temp-text "
294 - Item 1
295 - Item 2
296 - Item 2.1"
297 (search-forward "- Item 2")
298 (let (org-list-demote-modify-bullet) (org-indent-item-tree))
299 (should (equal (buffer-string)
301 - Item 1
302 - Item 2
303 - Item 2.1")))
304 ;; 3. Special case: When indenting top item, move the whole list.
305 (org-test-with-temp-text "
306 - Item 1
307 - Item 2"
308 (search-forward "- Item 1")
309 (let (org-list-demote-modify-bullet org-odd-levels-only)
310 (org-indent-item-tree))
311 (should (equal (buffer-string)
313 - Item 1
314 - Item 2")))
315 ;; 4. Follow `org-list-demote-modify-bullet' specifications.
317 ;; 4.1. With unordered lists.
318 (org-test-with-temp-text "
319 - Item 1
320 - Item 2
321 + Item 2.1"
322 (search-forward "- Item 2")
323 (let ((org-list-demote-modify-bullet '(("-" . "+") ("+" . "-"))))
324 (org-indent-item-tree))
325 (should (equal (buffer-string)
327 - Item 1
328 + Item 2
329 - Item 2.1")))
330 ;; 4.2. and ordered lists.
331 (org-test-with-temp-text "
332 1. Item 1
333 2. Item 2
334 + Item 2.1"
335 (search-forward "2. Item 2")
336 (let ((org-plain-list-ordered-item-terminator t)
337 (org-list-demote-modify-bullet '(("1." . "+") ("+" . "1."))))
338 (org-indent-item-tree))
339 (should (equal (buffer-string)
341 1. Item 1
342 + Item 2
343 1. Item 2.1")))
344 ;; 5. When a region is selected, indent every item within.
345 (org-test-with-temp-text "
346 - Item 1
347 - Item 2
348 - Item 2.1
349 - Item 3
350 - Item 3.1
352 (search-forward "- Item 2")
353 (beginning-of-line)
354 (transient-mark-mode 1)
355 (push-mark (point) t t)
356 (goto-char (point-max))
357 (let (org-list-demote-modify-bullet) (org-indent-item-tree))
358 (should (equal (buffer-string)
360 - Item 1
361 - Item 2
362 - Item 2.1
363 - Item 3
364 - Item 3.1
365 "))))
367 (ert-deftest test-org-list/outdent-item ()
368 "Test `org-outdent-item' specifications."
369 ;; 1. Error when not at an item.
370 (org-test-with-temp-text "Paragraph."
371 (should-error (org-outdent-item)))
372 ;; 2. Error when trying to move first item of a list.
373 (org-test-with-temp-text "
374 - Item 1
375 - Item 2"
376 (forward-line)
377 (should-error (org-outdent-item)))
378 ;; 3. Error when trying to outdent an item without its children.
379 (org-test-with-temp-text "
380 - Item 1
381 - Item 1.1
382 - Item 1.1.1"
383 (search-forward "- Item 1.1")
384 (should-error (org-outdent-item)))
385 ;; 4. Error when trying to outdent before top item.
386 (org-test-with-temp-text "
387 - Item 1
388 - Item 2"
389 (search-forward "- Item 2")
390 (should-error (org-outdent-item)))
391 ;; 5. When a region is selected, outdent every item within.
392 (org-test-with-temp-text "
393 - Item 1
394 - Item 2
395 - Item 3
397 (search-forward "- Item 2")
398 (beginning-of-line)
399 (transient-mark-mode 1)
400 (push-mark (point) t t)
401 (goto-char (point-max))
402 (let (org-list-demote-modify-bullet) (org-outdent-item))
403 (should (equal (buffer-string)
405 - Item 1
406 - Item 2
407 - Item 3
408 "))))
410 (ert-deftest test-org-list/outdent-item-tree ()
411 "Test `org-outdent-item-tree' specifications."
412 ;; 1. Error when not at an item.
413 (org-test-with-temp-text "Paragraph."
414 (should-error (org-outdent-item-tree)))
415 ;; 2. Error when trying to outdent before top item.
416 (org-test-with-temp-text "
417 - Item 1
418 - Item 2"
419 (search-forward "- Item 2")
420 (should-error (org-outdent-item-tree)))
421 ;; 3. Outdent item along with its children.
422 (org-test-with-temp-text "
423 - Item 1
424 - Item 2
425 - Item 2.1"
426 (search-forward "- Item 2")
427 (org-outdent-item-tree)
428 (should (equal (buffer-string)
430 - Item 1
431 - Item 2
432 - Item 2.1")))
433 ;; 3. Special case: When outdenting top item, move the whole list.
434 (org-test-with-temp-text "
435 - Item 1
436 - Item 2"
437 (search-forward "- Item 1")
438 (let (org-odd-levels-only) (org-outdent-item-tree))
439 (should (equal (buffer-string)
441 - Item 1
442 - Item 2")))
443 ;; 5. When a region is selected, outdent every item within.
444 (org-test-with-temp-text "
445 - Item 1
446 - Item 2
447 - Item 2.1
448 - Item 3
449 - Item 3.1
451 (search-forward "- Item 2")
452 (beginning-of-line)
453 (transient-mark-mode 1)
454 (push-mark (point) t t)
455 (goto-char (point-max))
456 (org-outdent-item-tree)
457 (should (equal (buffer-string)
459 - Item 1
460 - Item 2
461 - Item 2.1
462 - Item 3
463 - Item 3.1
464 "))))
466 (ert-deftest test-org-list/move-item-down ()
467 "Test `org-move-item-down' specifications."
468 ;; Standard test.
469 (org-test-with-temp-text "- item 1\n- item 2"
470 (org-move-item-down)
471 (should (equal (buffer-string)
472 "- item 2\n- item 1")))
473 ;; Keep same column in item.
474 (org-test-with-temp-text "- item 1\n- item 2"
475 (forward-char 4)
476 (org-move-item-down)
477 (should (looking-at "em 1")))
478 ;; Move sub-items.
479 (org-test-with-temp-text "- item 1\n - sub-item 1\n- item 2"
480 (org-move-item-down)
481 (should (equal (buffer-string)
482 "- item 2\n- item 1\n - sub-item 1")))
483 ;; Preserve blank lines.
484 (should
485 (equal
486 "- item 2\n\n- item 1"
487 (org-test-with-temp-text "- item 1\n\n- item 2"
488 (org-move-item-down)
489 (buffer-string))))
490 ;; Error when trying to move the last item...
491 (org-test-with-temp-text "- item 1\n- item 2"
492 (forward-line)
493 (should-error (org-move-item-down)))
494 ;; ... unless `org-list-use-circular-motion' is non-nil. In this
495 ;; case, move to the first item.
496 (org-test-with-temp-text "- item 1\n- item 2\n- item 3"
497 (forward-line 2)
498 (let ((org-list-use-circular-motion t)) (org-move-item-down))
499 (should (equal (buffer-string) "- item 3\n- item 1\n- item 2\n")))
500 ;; Preserve item visibility.
501 (org-test-with-temp-text "* Headline\n- item 1\n body 1\n- item 2\n body 2"
502 (let ((org-cycle-include-plain-lists t))
503 (search-forward "- item 1")
504 (org-cycle)
505 (search-forward "- item 2")
506 (org-cycle))
507 (search-backward "- item 1")
508 (org-move-item-down)
509 (forward-line)
510 (should (org-invisible-p2))
511 (search-backward " body 2")
512 (should (org-invisible-p2)))
513 ;; Preserve children visibility.
514 (org-test-with-temp-text "* Headline
515 - item 1
516 - sub-item 1
517 sub-body 1
518 - item 2
519 - sub-item 2
520 sub-body 2"
521 (let ((org-cycle-include-plain-lists t))
522 (search-forward "- sub-item 1")
523 (org-cycle)
524 (search-forward "- sub-item 2")
525 (org-cycle))
526 (search-backward "- item 1")
527 (org-move-item-down)
528 (search-forward "sub-body 1")
529 (should (org-invisible-p2))
530 (search-backward "sub-body 2")
531 (should (org-invisible-p2))))
533 (ert-deftest test-org-list/move-item-down-contents-visibility ()
534 "Preserve contents visibility."
535 (org-test-with-temp-text "
536 - item 1
537 #+BEGIN_CENTER
538 Text1
539 #+END_CENTER
540 - item 2
541 #+BEGIN_CENTER
542 Text2
543 #+END_CENTER"
544 (org-hide-block-all)
545 (let ((invisible-property-1
546 (progn
547 (search-forward "Text1")
548 (get-char-property (point) 'invisible)))
549 (invisible-property-2
550 (progn
551 (search-forward "Text2")
552 (get-char-property (point) 'invisible))))
553 (goto-char (point-min))
554 (search-forward "- item 1")
555 (org-move-item-down)
556 (search-forward "Text1")
557 (should (eq invisible-property-1 (get-char-property (point) 'invisible)))
558 (search-backward "Text2")
559 (should (eq invisible-property-2 (get-char-property (point) 'invisible))))))
561 (ert-deftest test-org-list/move-item-up ()
562 "Test `org-move-item-up' specifications."
563 ;; Standard test.
564 (org-test-with-temp-text "- item 1\n- item 2"
565 (forward-line)
566 (org-move-item-up)
567 (should (equal (buffer-string)
568 "- item 2\n- item 1")))
569 ;; Keep same column in item.
570 (org-test-with-temp-text "- item 1\n- item 2"
571 (forward-line)
572 (forward-char 4)
573 (org-move-item-up)
574 (should (looking-at "em 2")))
575 ;; Move sub-items.
576 (org-test-with-temp-text "- item 1\n- item 2\n - sub-item 2"
577 (forward-line)
578 (org-move-item-up)
579 (should (equal (buffer-string)
580 "- item 2\n - sub-item 2\n- item 1")))
581 ;; Preserve blank lines.
582 (should
583 (equal
584 "- item 2\n\n- item 1"
585 (org-test-with-temp-text "- item 1\n\n- item 2"
586 (search-forward "- item 2")
587 (org-move-item-up)
588 (buffer-string))))
589 ;; Error when trying to move the first item...
590 (org-test-with-temp-text "- item 1\n- item 2"
591 (should-error (org-move-item-up)))
592 ;; ... unless `org-list-use-circular-motion' is non-nil. In this
593 ;; case, move to the first item.
594 (org-test-with-temp-text "- item 1\n- item 2\n- item 3"
595 (let ((org-list-use-circular-motion t)) (org-move-item-up))
596 (should (equal (buffer-string) "- item 2\n- item 3\n- item 1")))
597 ;; Preserve item visibility.
598 (org-test-with-temp-text "* Headline\n- item 1\n body 1\n- item 2\n body 2"
599 (let ((org-cycle-include-plain-lists t))
600 (search-forward "- item 1")
601 (org-cycle)
602 (search-forward "- item 2")
603 (org-cycle))
604 (org-move-item-up)
605 (forward-line)
606 (should (org-invisible-p2))
607 (search-forward " body 1")
608 (should (org-invisible-p2)))
609 ;; Preserve children visibility.
610 (org-test-with-temp-text "* Headline
611 - item 1
612 - sub-item 1
613 sub-body 1
614 - item 2
615 - sub-item 2
616 sub-body 2"
617 (let ((org-cycle-include-plain-lists t))
618 (search-forward "- sub-item 1")
619 (org-cycle)
620 (search-forward "- sub-item 2")
621 (org-cycle))
622 (search-backward "- item 2")
623 (org-move-item-up)
624 (search-forward "sub-body 2")
625 (should (org-invisible-p2))
626 (search-forward "sub-body 1")
627 (should (org-invisible-p2))))
629 (ert-deftest test-org-list/move-item-up-contents-visibility ()
630 (org-test-with-temp-text "
631 - item 1
632 #+BEGIN_CENTER
633 Text1
634 #+END_CENTER
635 - item 2
636 #+BEGIN_CENTER
637 Text2
638 #+END_CENTER"
639 (org-hide-block-all)
640 (let ((invisible-property-1
641 (progn
642 (search-forward "Text1")
643 (get-char-property (point) 'invisible)))
644 (invisible-property-2
645 (progn
646 (search-forward "Text2")
647 (get-char-property (point) 'invisible))))
648 (goto-char (point-min))
649 (search-forward "- item 2")
650 (org-move-item-up)
651 (search-forward "Text2")
652 (should (eq invisible-property-2 (get-char-property (point) 'invisible)))
653 (search-forward "Text1")
654 (should (eq invisible-property-1 (get-char-property (point) 'invisible))))))
656 (ert-deftest test-org-list/insert-item ()
657 "Test item insertion."
658 ;; Blank lines specifications.
660 ;; Non-nil `org-blank-before-new-entry': insert a blank line.
661 (should
662 (org-test-with-temp-text "- a"
663 (let ((org-blank-before-new-entry '((plain-list-item . t))))
664 (end-of-line)
665 (org-insert-item)
666 (forward-line -1)
667 (looking-at "$"))))
668 ;; Nil `org-blank-before-new-entry': do not insert a blank line.
669 (should-not
670 (org-test-with-temp-text "- a"
671 (let ((org-blank-before-new-entry '((plain-list-item . nil))))
672 (end-of-line)
673 (org-insert-item)
674 (forward-line -1)
675 (looking-at "$"))))
676 ;; `org-blank-before-new-entry' set to auto: if there's no blank
677 ;; line already in the sole item, do not insert one.
678 (should-not
679 (org-test-with-temp-text "- a"
680 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
681 (end-of-line)
682 (org-insert-item)
683 (forward-line -1)
684 (looking-at "$"))))
685 ;; `org-blank-before-new-entry' set to `auto': if there's a blank
686 ;; line in the sole item, insert another one.
687 (should
688 (org-test-with-temp-text "- a\n\n b<point>"
689 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
690 (org-insert-item)
691 (forward-line -1)
692 (looking-at "$"))))
693 ;; `org-blank-before-new-entry' set to `auto': if the user specified
694 ;; a blank line, preserve it.
695 (should
696 (org-test-with-temp-text "- a\n\n<point>"
697 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
698 (org-insert-item)
699 (forward-line -1)
700 (looking-at "$"))))
701 ;; `org-blank-before-new-entry' set to `auto': if some items in list
702 ;; are already separated by blank lines, insert one.
703 (should
704 (org-test-with-temp-text "- a\n\n- b<point>"
705 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
706 (org-insert-item)
707 (forward-line -1)
708 (looking-at "$"))))
709 (should
710 (org-test-with-temp-text "- a\n\n- b"
711 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
712 (org-insert-item)
713 (forward-line)
714 (looking-at "$"))))
715 (should
716 (org-test-with-temp-text
717 "- a\n #+BEGIN_EXAMPLE\n\n x\n #+END_EXAMPLE<point>"
718 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
719 (org-insert-item)
720 (forward-line -1)
721 (looking-at "$"))))
722 ;; When called before or on the bullet, insert new item before
723 ;; current one.
724 (should
725 (equal "- \n- item"
726 (org-test-with-temp-text "- item"
727 (org-insert-item)
728 (buffer-string))))
729 (should
730 (equal "- \n- item"
731 (org-test-with-temp-text "- <point>item"
732 (org-insert-item)
733 (buffer-string))))
734 ;; When called on tag in a descriptive list, insert new item before
735 ;; current one too.
736 (should
737 (equal "- :: \n- tag :: item"
738 (org-test-with-temp-text "- tag <point>:: item"
739 (org-insert-item)
740 (buffer-string))))
741 (should
742 (equal "- :: \n- tag :: item"
743 (org-test-with-temp-text "- ta<point>g :: item"
744 (org-insert-item)
745 (buffer-string))))
746 ;; Further, it splits the line or add a blank new item after it,
747 ;; according to `org-M-RET-may-split-line'.
748 (should
749 (equal "- it\n- em"
750 (org-test-with-temp-text "- it<point>em"
751 (let ((org-M-RET-may-split-line '((default . t))))
752 (org-insert-item))
753 (buffer-string))))
754 (should
755 (equal "- item\n- "
756 (org-test-with-temp-text "- it<point>em"
757 (let ((org-M-RET-may-split-line '((default . nil))))
758 (org-insert-item))
759 (buffer-string))))
760 ;; Preserve list visibility when inserting an item.
761 (should
762 (equal
763 '(outline outline)
764 (org-test-with-temp-text "- A\n - B\n- C\n - D"
765 (let ((org-cycle-include-plain-lists t))
766 (org-cycle)
767 (forward-line 2)
768 (org-cycle)
769 (org-insert-item)
770 (list (get-char-property (line-beginning-position 0) 'invisible)
771 (get-char-property (line-end-position 2) 'invisible)))))))
773 (ert-deftest test-org-list/repair ()
774 "Test `org-list-repair' specifications."
775 ;; Repair indentation.
776 (should
777 (equal "- item\n - child"
778 (org-test-with-temp-text "- item\n - child"
779 (let ((org-list-indent-offset 0)) (org-list-repair))
780 (buffer-string))))
781 ;; Repair bullets and numbering.
782 (should
783 (equal "- a\n- b"
784 (org-test-with-temp-text "- a\n+ b"
785 (let ((org-list-indent-offset 0))
786 (org-list-repair))
787 (buffer-string))))
788 (should
789 (equal "1. a\n2. b"
790 (org-test-with-temp-text "1. a\n1. b"
791 (let ((org-list-indent-offset 0)
792 (org-plain-list-ordered-item-terminator t))
793 (org-list-repair))
794 (buffer-string))))
795 ;; Repair check-boxes.
796 (should
797 (equal "- [X] item\n - [X] child"
798 (org-test-with-temp-text "- [ ] item\n - [X] child"
799 (let ((org-list-indent-offset 0))
800 (org-list-repair))
801 (buffer-string))))
802 ;; Special case: do not move contents of an item within its child.
803 ;; Yet, preserve indentation differences within contents.
804 (should
805 (equal "- item\n - child\n within item"
806 (org-test-with-temp-text "- item\n - child\n within item"
807 (let ((org-list-indent-offset 0)) (org-list-repair))
808 (buffer-string))))
809 (should
810 (equal
811 "- item\n - child\n within item\n indented"
812 (org-test-with-temp-text
813 "- item\n - child\n within item\n indented"
814 (let ((org-list-indent-offset 0)) (org-list-repair))
815 (buffer-string)))))
817 (ert-deftest test-org-list/update-checkbox-count ()
818 "Test `org-update-checkbox-count' specifications."
819 ;; From a headline.
820 (should
821 (string-match "\\[0/1\\]"
822 (org-test-with-temp-text "* [/]\n- [ ] item"
823 (org-update-checkbox-count)
824 (buffer-string))))
825 (should
826 (string-match "\\[1/1\\]"
827 (org-test-with-temp-text "* [/]\n- [X] item"
828 (org-update-checkbox-count)
829 (buffer-string))))
830 (should
831 (string-match "\\[100%\\]"
832 (org-test-with-temp-text "* [%]\n- [X] item"
833 (org-update-checkbox-count)
834 (buffer-string))))
835 ;; From a list or a sub-list.
836 (should
837 (string-match "\\[0/1\\]"
838 (org-test-with-temp-text "- [/]\n - [ ] item"
839 (org-update-checkbox-count)
840 (buffer-string))))
841 (should
842 (string-match "\\[1/1\\]"
843 (org-test-with-temp-text "- [/]\n - [X] item"
844 (org-update-checkbox-count)
845 (buffer-string))))
846 (should
847 (string-match "\\[100%\\]"
848 (org-test-with-temp-text "- [%]\n - [X] item"
849 (org-update-checkbox-count)
850 (buffer-string))))
851 (should
852 (string-match
853 "\\[1/1\\]"
854 (org-test-with-temp-text "- [ ] item 1\n- [ ] item 2 [/]\n - [X] sub 1"
855 (org-update-checkbox-count)
856 (buffer-string))))
857 ;; Count do not apply to sub-lists unless count is not hierarchical.
858 ;; This state can be achieved with COOKIE_DATA node property set to
859 ;; "recursive".
860 (should
861 (string-match "\\[1/1\\]"
862 (org-test-with-temp-text "- [/]\n - item\n - [X] sub-item"
863 (let ((org-checkbox-hierarchical-statistics nil))
864 (org-update-checkbox-count))
865 (buffer-string))))
866 (should
867 (string-match "\\[1/1\\]"
868 (org-test-with-temp-text "
869 <point>* H
870 :PROPERTIES:
871 :COOKIE_DATA: recursive
872 :END:
873 - [/]
874 - item
875 - [X] sub-item"
876 (org-update-checkbox-count)
877 (buffer-string))))
878 (should
879 (string-match "\\[0/0\\]"
880 (org-test-with-temp-text "- [/]\n - item\n - [ ] sub-item"
881 (org-update-checkbox-count)
882 (buffer-string))))
883 ;; With optional argument ALL, update all buffer.
884 (should
885 (= 2
886 (org-test-with-temp-text "* [/]\n- [X] item\n* [/]\n- [X] item"
887 (org-update-checkbox-count t)
888 (count-matches "\\[1/1\\]"))))
889 ;; Ignore boxes in drawers, blocks or inlinetasks when counting from
890 ;; outside.
891 (should
892 (string-match "\\[2/2\\]"
893 (org-test-with-temp-text "
894 - [/]
895 - [X] item1
896 :DRAWER:
897 - [X] item
898 :END:
899 - [X] item2"
900 (let ((org-checkbox-hierarchical-statistics nil))
901 (org-update-checkbox-count))
902 (buffer-string)))))
906 ;;; Miscellaneous
908 (ert-deftest test-org-list/toggle-item ()
909 "Test `org-toggle-item' specifications."
910 ;; Convert normal lines to items.
911 (should
912 (equal "- line"
913 (org-test-with-temp-text "line"
914 (org-toggle-item nil)
915 (buffer-string))))
916 ;; Convert items to normal lines.
917 (should
918 (equal "line"
919 (org-test-with-temp-text "- line"
920 (org-toggle-item nil)
921 (buffer-string))))
922 ;; Convert headlines to items.
923 (should
924 (equal "- line"
925 (org-test-with-temp-text "* line"
926 (org-toggle-item nil)
927 (buffer-string))))
928 ;; When converting a headline to a list item, TODO keywords become
929 ;; checkboxes.
930 (should
931 (equal "- [X] line"
932 (org-test-with-temp-text "* DONE line"
933 (org-toggle-item nil)
934 (buffer-string))))
935 (should
936 (equal "- [ ] line"
937 (org-test-with-temp-text "* TODO line"
938 (org-toggle-item nil)
939 (buffer-string))))
940 ;; When turning headlines into items, make sure planning info line
941 ;; and properties drawers are removed. This also includes empty
942 ;; lines following them.
943 (should
944 (equal "- H\n"
945 (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29 Thu>"
946 (org-toggle-item nil)
947 (buffer-string))))
948 (should
949 (equal "- H\n"
950 (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:"
951 (org-toggle-item nil)
952 (buffer-string))))
953 (should
954 (equal "- H\nText"
955 (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n\n\nText"
956 (org-toggle-item nil)
957 (buffer-string))))
958 ;; When a region is marked and first line is a headline, all
959 ;; headlines are turned into items.
960 (should
961 (equal "- H1\n - H2"
962 (org-test-with-temp-text "* H1\n** H2"
963 (transient-mark-mode 1)
964 (push-mark (point) t t)
965 (goto-char (point-max))
966 (org-toggle-item nil)
967 (buffer-string))))
968 (should
969 (equal "- [ ] H1\n - [ ] H2"
970 (org-test-with-temp-text "* TODO H1\n** TODO H2"
971 (transient-mark-mode 1)
972 (push-mark (point) t t)
973 (goto-char (point-max))
974 (org-toggle-item nil)
975 (buffer-string))))
976 ;; When turning headlines into items, make sure headings contents
977 ;; are kept within items.
978 (should
979 (equal "- H1\n Text"
980 (org-test-with-temp-text "* H1\nText"
981 (transient-mark-mode 1)
982 (push-mark (point) t t)
983 (goto-char (point-max))
984 (org-toggle-item nil)
985 (buffer-string))))
986 ;; When a region is marked and first line is an item, all items are
987 ;; turned into normal lines.
988 (should
989 (equal "1\n 2"
990 (org-test-with-temp-text "- 1\n - 2"
991 (transient-mark-mode 1)
992 (push-mark (point) t t)
993 (goto-char (point-max))
994 (org-toggle-item nil)
995 (buffer-string))))
996 (should
997 (equal "1\n2"
998 (org-test-with-temp-text "- 1\n2"
999 (transient-mark-mode 1)
1000 (push-mark (point) t t)
1001 (goto-char (point-max))
1002 (org-toggle-item nil)
1003 (buffer-string))))
1004 ;; When a region is marked and first line is an item, all normal
1005 ;; lines are turned into items.
1006 (should
1007 (equal "- line 1\n- line 2"
1008 (org-test-with-temp-text "line 1\nline 2"
1009 (transient-mark-mode 1)
1010 (push-mark (point) t t)
1011 (goto-char (point-max))
1012 (org-toggle-item nil)
1013 (buffer-string))))
1014 (should
1015 (equal "- line 1\n- line 2"
1016 (org-test-with-temp-text "line 1\n- line 2"
1017 (transient-mark-mode 1)
1018 (push-mark (point) t t)
1019 (goto-char (point-max))
1020 (org-toggle-item nil)
1021 (buffer-string))))
1022 ;; When argument ARG is non-nil, change the whole region into
1023 ;; a single item.
1024 (should
1025 (equal "- line 1\n line 2"
1026 (org-test-with-temp-text "line 1\nline 2"
1027 (transient-mark-mode 1)
1028 (push-mark (point) t t)
1029 (goto-char (point-max))
1030 (org-toggle-item t)
1031 (buffer-string)))))
1033 (ert-deftest test-org-list/sort ()
1034 "Test `org-sort-list'."
1035 ;; Sort alphabetically.
1036 (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
1037 (cl-letf (((symbol-function 'string-collate-lessp)
1038 (lambda (s1 s2 &optional locale ignore-case)
1039 (funcall original-string-collate-lessp
1040 s1 s2 "C" ignore-case))))
1041 (should
1042 (equal "- abc\n- def\n- XYZ\n"
1043 (org-test-with-temp-text "- def\n- XYZ\n- abc\n"
1044 (org-sort-list nil ?a)
1045 (buffer-string))))
1046 (should
1047 (equal "- XYZ\n- def\n- abc\n"
1048 (org-test-with-temp-text "- def\n- XYZ\n- abc\n"
1049 (org-sort-list nil ?A)
1050 (buffer-string))))
1051 ;; Sort alphabetically (with case).
1052 (should
1053 (equal "- C\n- a\n- b\n"
1054 (org-test-with-temp-text "- b\n- C\n- a\n"
1055 (org-sort-list t ?a)
1056 (buffer-string))))
1057 (should
1058 (equal "- b\n- a\n- C\n"
1059 (org-test-with-temp-text "- b\n- C\n- a\n"
1060 (org-sort-list t ?A)
1061 (buffer-string))))))
1062 ;; Sort numerically.
1063 (should
1064 (equal "- 1\n- 2\n- 10\n"
1065 (org-test-with-temp-text "- 10\n- 1\n- 2\n"
1066 (org-sort-list nil ?n)
1067 (buffer-string))))
1068 (should
1069 (equal "- 10\n- 2\n- 1\n"
1070 (org-test-with-temp-text "- 10\n- 1\n- 2\n"
1071 (org-sort-list nil ?N)
1072 (buffer-string))))
1073 ;; Sort by checked status.
1074 (should
1075 (equal "- [ ] xyz\n- [ ] def\n- [X] abc\n"
1076 (org-test-with-temp-text "- [X] abc\n- [ ] xyz\n- [ ] def\n"
1077 (org-sort-list nil ?x)
1078 (buffer-string))))
1079 (should
1080 (equal "- [X] abc\n- [ ] xyz\n- [ ] def\n"
1081 (org-test-with-temp-text "- [X] abc\n- [ ] xyz\n- [ ] def\n"
1082 (org-sort-list nil ?X)
1083 (buffer-string))))
1084 ;; Sort by time stamp.
1085 (should
1086 (equal "- <2017-05-08 Mon>\n- <2017-05-09 Tue>\n- <2018-05-09 Wed>\n"
1087 (org-test-with-temp-text
1088 "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
1089 (org-sort-list nil ?t)
1090 (buffer-string))))
1091 (should
1092 (equal "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
1093 (org-test-with-temp-text
1094 "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
1095 (org-sort-list nil ?T)
1096 (buffer-string))))
1097 ;; Sort by custom function.
1098 (should
1099 (equal "- b\n- aa\n- ccc\n"
1100 (org-test-with-temp-text "- ccc\n- b\n- aa\n"
1101 (org-sort-list nil ?f
1102 (lambda ()
1103 (length (buffer-substring (point-at-bol)
1104 (point-at-eol))))
1105 #'<)
1106 (buffer-string))))
1107 (should
1108 (equal "- ccc\n- aa\n- b\n"
1109 (org-test-with-temp-text "- ccc\n- b\n- aa\n"
1110 (org-sort-list nil ?F
1111 (lambda ()
1112 (length (buffer-substring (point-at-bol)
1113 (point-at-eol))))
1114 #'<)
1115 (buffer-string)))))
1118 ;;; List transformations
1120 (ert-deftest test-org-list/to-generic ()
1121 "Test `org-list-to-generic' specifications."
1122 ;; Test `:ustart' and `:uend' parameters.
1123 (should
1124 (equal
1125 "begin\na"
1126 (org-test-with-temp-text "- a"
1127 (org-list-to-generic (org-list-to-lisp) '(:ustart "begin")))))
1128 (should-not
1129 (equal
1130 "begin\na"
1131 (org-test-with-temp-text "1. a"
1132 (org-list-to-generic (org-list-to-lisp) '(:ustart "begin")))))
1133 (should
1134 (equal
1135 "a\nend"
1136 (org-test-with-temp-text "- a"
1137 (org-list-to-generic (org-list-to-lisp) '(:uend "end")))))
1138 (should-not
1139 (equal
1140 "a\nend"
1141 (org-test-with-temp-text "1. a"
1142 (org-list-to-generic (org-list-to-lisp) '(:uend "end")))))
1143 (should
1144 (equal
1145 "begin l1\na\nbegin l2\nb\nend l2\nend l1"
1146 (org-test-with-temp-text "- a\n - b"
1147 (org-list-to-generic
1148 (org-list-to-lisp)
1149 (list :ustart (lambda (l) (format "begin l%d" l))
1150 :uend (lambda (l) (format "end l%d" l)))))))
1151 ;; Test `:ostart' and `:oend' parameters.
1152 (should
1153 (equal
1154 "begin\na"
1155 (org-test-with-temp-text "1. a"
1156 (org-list-to-generic (org-list-to-lisp) '(:ostart "begin")))))
1157 (should-not
1158 (equal
1159 "begin\na"
1160 (org-test-with-temp-text "- a"
1161 (org-list-to-generic (org-list-to-lisp) '(:ostart "begin")))))
1162 (should
1163 (equal
1164 "a\nend"
1165 (org-test-with-temp-text "1. a"
1166 (org-list-to-generic (org-list-to-lisp) '(:oend "end")))))
1167 (should-not
1168 (equal
1169 "a\nend"
1170 (org-test-with-temp-text "- a"
1171 (org-list-to-generic (org-list-to-lisp) '(:oend "end")))))
1172 (should
1173 (equal
1174 "begin l1\na\nbegin l2\nb\nend l2\nend l1"
1175 (org-test-with-temp-text "1. a\n 1. b"
1176 (org-list-to-generic
1177 (org-list-to-lisp)
1178 (list :ostart (lambda (l) (format "begin l%d" l))
1179 :oend (lambda (l) (format "end l%d" l)))))))
1180 ;; Test `:dstart' and `:dend' parameters.
1181 (should
1182 (equal
1183 "begin\ntaga"
1184 (org-test-with-temp-text "- tag :: a"
1185 (org-list-to-generic (org-list-to-lisp) '(:dstart "begin")))))
1186 (should-not
1187 (equal
1188 "begin\na"
1189 (org-test-with-temp-text "- a"
1190 (org-list-to-generic (org-list-to-lisp) '(:dstart "begin")))))
1191 (should
1192 (equal
1193 "taga\nend"
1194 (org-test-with-temp-text "- tag :: a"
1195 (org-list-to-generic (org-list-to-lisp) '(:dend "end")))))
1196 (should-not
1197 (equal
1198 "a\nend"
1199 (org-test-with-temp-text "- a"
1200 (org-list-to-generic (org-list-to-lisp) '(:dend "end")))))
1201 (should
1202 (equal
1203 "begin l1\ntag1a\nbegin l2\ntag2b\nend l2\nend l1"
1204 (org-test-with-temp-text "- tag1 :: a\n - tag2 :: b"
1205 (org-list-to-generic
1206 (org-list-to-lisp)
1207 (list :dstart (lambda (l) (format "begin l%d" l))
1208 :dend (lambda (l) (format "end l%d" l)))))))
1209 ;; Test `:dtstart', `:dtend', `:ddstart' and `:ddend' parameters.
1210 (should
1211 (equal
1212 ">tag<a"
1213 (org-test-with-temp-text "- tag :: a"
1214 (org-list-to-generic (org-list-to-lisp) '(:dtstart ">" :dtend "<")))))
1215 (should
1216 (equal
1217 "tag>a<"
1218 (org-test-with-temp-text "- tag :: a"
1219 (org-list-to-generic (org-list-to-lisp) '(:ddstart ">" :ddend "<")))))
1220 ;; Test `:istart' and `:iend' parameters.
1221 (should
1222 (equal
1223 "starta"
1224 (org-test-with-temp-text "- a"
1225 (org-list-to-generic (org-list-to-lisp) '(:istart "start")))))
1226 (should
1227 (equal
1228 "level1 a\nlevel2 b"
1229 (org-test-with-temp-text "- a\n - b"
1230 (org-list-to-generic (org-list-to-lisp)
1231 '(:istart (lambda (type l) (format "level%d "l)))))))
1232 (should
1233 (equal
1234 "a\nblevel2level1"
1235 (org-test-with-temp-text "- a\n - b"
1236 (org-list-to-generic (org-list-to-lisp)
1237 '(:iend (lambda (type l) (format "level%d" l)))))))
1238 ;; Test `:icount' parameter.
1239 (should
1240 (equal
1241 "counta"
1242 (org-test-with-temp-text "1. [@3] a"
1243 (org-list-to-generic (org-list-to-lisp) '(:icount "count")))))
1244 (should-not
1245 (equal
1246 "counta"
1247 (org-test-with-temp-text "1. a"
1248 (org-list-to-generic (org-list-to-lisp) '(:icount "count")))))
1249 (should
1250 (equal
1251 "counta"
1252 (org-test-with-temp-text "1. [@3] a"
1253 (org-list-to-generic (org-list-to-lisp)
1254 '(:icount "count" :istart "start")))))
1255 (should
1256 (equal
1257 "level:1, counter:3 a"
1258 (org-test-with-temp-text "1. [@3] a"
1259 (org-list-to-generic
1260 (org-list-to-lisp)
1261 '(:icount (lambda (type l c) (format "level:%d, counter:%d " l c)))))))
1262 ;; Test `:isep' parameter.
1263 (should
1264 (equal
1265 "a\n--\nb"
1266 (org-test-with-temp-text "- a\n- b"
1267 (org-list-to-generic (org-list-to-lisp) '(:isep "--")))))
1268 (should-not
1269 (equal
1270 "a\n--\nb"
1271 (org-test-with-temp-text "- a\n - b"
1272 (org-list-to-generic (org-list-to-lisp) '(:isep "--")))))
1273 (should
1274 (equal
1275 "a\n- 1 -\nb"
1276 (org-test-with-temp-text "- a\n- b"
1277 (org-list-to-generic
1278 (org-list-to-lisp)
1279 '(:isep (lambda (type depth) (format "- %d -" depth)))))))
1280 ;; Test `:ifmt' parameter.
1281 (should
1282 (equal
1283 ">> a <<"
1284 (org-test-with-temp-text "1. [@3] a"
1285 (org-list-to-generic
1286 (org-list-to-lisp)
1287 '(:ifmt (lambda (type c) (format ">> %s <<" c)))))))
1288 ;; Test `:cbon', `:cboff', `:cbtrans'
1289 (should
1290 (equal
1291 "!a"
1292 (org-test-with-temp-text "- [X] a"
1293 (org-list-to-generic (org-list-to-lisp) '(:cbon "!")))))
1294 (should-not
1295 (equal
1296 "!a"
1297 (org-test-with-temp-text "- [X] a"
1298 (org-list-to-generic (org-list-to-lisp) '(:cboff "!" :cbtrans "!")))))
1299 (should
1300 (equal
1301 "!a"
1302 (org-test-with-temp-text "- [ ] a"
1303 (org-list-to-generic (org-list-to-lisp) '(:cboff "!")))))
1304 (should-not
1305 (equal
1306 "!a"
1307 (org-test-with-temp-text "- [ ] a"
1308 (org-list-to-generic (org-list-to-lisp) '(:cbon "!" :cbtrans "!")))))
1309 (should
1310 (equal
1311 "!a"
1312 (org-test-with-temp-text "- [-] a"
1313 (org-list-to-generic (org-list-to-lisp) '(:cbtrans "!")))))
1314 (should-not
1315 (equal
1316 "!a"
1317 (org-test-with-temp-text "- [-] a"
1318 (org-list-to-generic (org-list-to-lisp) '(:cbon "!" :cboff "!")))))
1319 ;; Test `:splice' parameter.
1320 (should
1321 (equal
1323 (org-test-with-temp-text "- a"
1324 (org-list-to-generic (org-list-to-lisp)
1325 '(:ustart "begin" :uend "end" :splice t)))))
1326 ;; No error on empty lists.
1327 (should
1328 (org-test-with-temp-text "-" (org-list-to-generic (org-list-to-lisp) nil))))
1330 (ert-deftest test-org-list/to-html ()
1331 "Test `org-list-to-html' specifications."
1332 (should
1333 (equal "<ul class=\"org-ul\">\n<li>a</li>\n</ul>"
1334 (org-test-with-temp-text "- a"
1335 (org-list-to-html (org-list-to-lisp) nil)))))
1337 (ert-deftest test-org-list/to-latex ()
1338 "Test `org-list-to-latex' specifications."
1339 (should
1340 (equal "\\begin{itemize}\n\\item a\n\\end{itemize}"
1341 (org-test-with-temp-text "- a"
1342 (org-list-to-latex (org-list-to-lisp) nil)))))
1344 (ert-deftest test-org-list/to-texinfo ()
1345 "Test `org-list-to-texinfo' specifications."
1346 (should
1347 (equal "@itemize\n@item\na\n@end itemize"
1348 (org-test-with-temp-text "- a"
1349 (org-list-to-texinfo (org-list-to-lisp) nil)))))
1351 (ert-deftest test-org-list/to-org ()
1352 "Test `org-list-to-org' specifications."
1353 ;; Un-ordered list.
1354 (should
1355 (equal "- a"
1356 (org-test-with-temp-text "- a"
1357 (org-list-to-org (org-list-to-lisp) nil))))
1358 ;; Ordered list.
1359 (should
1360 (equal "1. a"
1361 (org-test-with-temp-text "1. a"
1362 (org-list-to-org (org-list-to-lisp) nil))))
1363 ;; Descriptive list.
1364 (should
1365 (equal "- a :: b"
1366 (org-test-with-temp-text "- a :: b"
1367 (org-list-to-org (org-list-to-lisp) nil))))
1368 ;; Nested list.
1369 (should
1370 (equal "- a\n - b"
1371 (org-test-with-temp-text "- a\n - b"
1372 (org-list-to-org (org-list-to-lisp) nil))))
1373 ;; Item spanning over multiple lines.
1374 (should
1375 (equal "- a\n b"
1376 (org-test-with-temp-text "- a\n b"
1377 (org-list-to-org (org-list-to-lisp) nil))))
1378 ;; Item with continuation text after a sub-list.
1379 (should
1380 (equal "- a\n - b\n c"
1381 (org-test-with-temp-text "- a\n - b\n c"
1382 (org-list-to-org (org-list-to-lisp) nil)))))
1385 (provide 'test-org-list)
1386 ;;; test-org-list.el ends here