Fix opening custom ID links with percent escaped syntax
[org-mode/org-tableheadings.git] / testing / lisp / test-org-list.el
blob019e257d38c1c82bae80dec458d5631dae2b8492
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 ;; Error when not at an item.
224 (org-test-with-temp-text "Paragraph."
225 (should-error (org-indent-item)))
226 ;; Error when trying to move first item of a list.
227 (should-error
228 (org-test-with-temp-text "
229 - Item 1
230 - Item 2"
231 (forward-line)
232 (org-indent-item)))
233 (should-error
234 (org-test-with-temp-text "
235 - Item 1
236 - Item 2"
237 (forward-line)
238 (let ((org-list-automatic-rules nil)) (org-indent-item))))
239 ;; Indent a single item, not its children.
240 (should
241 (equal "
242 - Item 1
243 - Item 2
244 - Item 2.1"
245 (org-test-with-temp-text "
246 - Item 1
247 - Item 2<point>
248 - Item 2.1"
249 (let (org-list-demote-modify-bullet) (org-indent-item))
250 (buffer-string))))
251 ;; Follow `org-list-demote-modify-bullet' specifications.
252 (should
253 (equal "
254 - Item 1
255 + Item 2"
256 (org-test-with-temp-text "
257 - Item 1
258 - Item 2<point>"
259 (let ((org-list-demote-modify-bullet '(("-" . "+"))))
260 (org-indent-item))
261 (buffer-string))))
262 (should
263 (equal "
264 1. Item 1
265 + Item 2"
266 (org-test-with-temp-text "
267 1. Item 1
268 2. Item 2<point>"
269 (let ((org-plain-list-ordered-item-terminator t)
270 (org-list-demote-modify-bullet '(("1." . "+"))))
271 (org-indent-item))
272 (buffer-string))))
273 ;; When a region is selected, indent every item within.
274 (should
275 (equal "
276 - Item 1
277 - Item 2
278 - Item 3
280 (org-test-with-temp-text "
281 - Item 1
282 <point>- Item 2
283 - Item 3
285 (transient-mark-mode 1)
286 (push-mark (point) t t)
287 (goto-char (point-max))
288 (let (org-list-demote-modify-bullet) (org-indent-item))
289 (buffer-string)))))
291 (ert-deftest test-org-list/indent-item-tree ()
292 "Test `org-indent-item-tree' specifications."
293 ;; 1. Error when not at an item.
294 (org-test-with-temp-text "Paragraph."
295 (should-error (org-indent-item-tree)))
296 ;; 2. Indent item along with its children.
297 (org-test-with-temp-text "
298 - Item 1
299 - Item 2
300 - Item 2.1"
301 (search-forward "- Item 2")
302 (let (org-list-demote-modify-bullet) (org-indent-item-tree))
303 (should (equal (buffer-string)
305 - Item 1
306 - Item 2
307 - Item 2.1")))
308 ;; 3. Special case: When indenting top item, move the whole list.
309 (org-test-with-temp-text "
310 - Item 1
311 - Item 2"
312 (search-forward "- Item 1")
313 (let (org-list-demote-modify-bullet org-odd-levels-only)
314 (org-indent-item-tree))
315 (should (equal (buffer-string)
317 - Item 1
318 - Item 2")))
319 ;; 4. Follow `org-list-demote-modify-bullet' specifications.
321 ;; 4.1. With unordered lists.
322 (org-test-with-temp-text "
323 - Item 1
324 - Item 2
325 + Item 2.1"
326 (search-forward "- Item 2")
327 (let ((org-list-demote-modify-bullet '(("-" . "+") ("+" . "-"))))
328 (org-indent-item-tree))
329 (should (equal (buffer-string)
331 - Item 1
332 + Item 2
333 - Item 2.1")))
334 ;; 4.2. and ordered lists.
335 (org-test-with-temp-text "
336 1. Item 1
337 2. Item 2
338 + Item 2.1"
339 (search-forward "2. Item 2")
340 (let ((org-plain-list-ordered-item-terminator t)
341 (org-list-demote-modify-bullet '(("1." . "+") ("+" . "1."))))
342 (org-indent-item-tree))
343 (should (equal (buffer-string)
345 1. Item 1
346 + Item 2
347 1. Item 2.1")))
348 ;; 5. When a region is selected, indent every item within.
349 (org-test-with-temp-text "
350 - Item 1
351 - Item 2
352 - Item 2.1
353 - Item 3
354 - Item 3.1
356 (search-forward "- Item 2")
357 (beginning-of-line)
358 (transient-mark-mode 1)
359 (push-mark (point) t t)
360 (goto-char (point-max))
361 (let (org-list-demote-modify-bullet) (org-indent-item-tree))
362 (should (equal (buffer-string)
364 - Item 1
365 - Item 2
366 - Item 2.1
367 - Item 3
368 - Item 3.1
369 "))))
371 (ert-deftest test-org-list/outdent-item ()
372 "Test `org-outdent-item' specifications."
373 ;; 1. Error when not at an item.
374 (org-test-with-temp-text "Paragraph."
375 (should-error (org-outdent-item)))
376 ;; 2. Error when trying to move first item of a list.
377 (org-test-with-temp-text "
378 - Item 1
379 - Item 2"
380 (forward-line)
381 (should-error (org-outdent-item)))
382 ;; 3. Error when trying to outdent an item without its children.
383 (org-test-with-temp-text "
384 - Item 1
385 - Item 1.1
386 - Item 1.1.1"
387 (search-forward "- Item 1.1")
388 (should-error (org-outdent-item)))
389 ;; 4. Error when trying to outdent before top item.
390 (org-test-with-temp-text "
391 - Item 1
392 - Item 2"
393 (search-forward "- Item 2")
394 (should-error (org-outdent-item)))
395 ;; 5. When a region is selected, outdent every item within.
396 (org-test-with-temp-text "
397 - Item 1
398 - Item 2
399 - Item 3
401 (search-forward "- Item 2")
402 (beginning-of-line)
403 (transient-mark-mode 1)
404 (push-mark (point) t t)
405 (goto-char (point-max))
406 (let (org-list-demote-modify-bullet) (org-outdent-item))
407 (should (equal (buffer-string)
409 - Item 1
410 - Item 2
411 - Item 3
412 "))))
414 (ert-deftest test-org-list/outdent-item-tree ()
415 "Test `org-outdent-item-tree' specifications."
416 ;; 1. Error when not at an item.
417 (org-test-with-temp-text "Paragraph."
418 (should-error (org-outdent-item-tree)))
419 ;; 2. Error when trying to outdent before top item.
420 (org-test-with-temp-text "
421 - Item 1
422 - Item 2"
423 (search-forward "- Item 2")
424 (should-error (org-outdent-item-tree)))
425 ;; 3. Outdent item along with its children.
426 (org-test-with-temp-text "
427 - Item 1
428 - Item 2
429 - Item 2.1"
430 (search-forward "- Item 2")
431 (org-outdent-item-tree)
432 (should (equal (buffer-string)
434 - Item 1
435 - Item 2
436 - Item 2.1")))
437 ;; 3. Special case: When outdenting top item, move the whole list.
438 (org-test-with-temp-text "
439 - Item 1
440 - Item 2"
441 (search-forward "- Item 1")
442 (let (org-odd-levels-only) (org-outdent-item-tree))
443 (should (equal (buffer-string)
445 - Item 1
446 - Item 2")))
447 ;; 5. When a region is selected, outdent every item within.
448 (org-test-with-temp-text "
449 - Item 1
450 - Item 2
451 - Item 2.1
452 - Item 3
453 - Item 3.1
455 (search-forward "- Item 2")
456 (beginning-of-line)
457 (transient-mark-mode 1)
458 (push-mark (point) t t)
459 (goto-char (point-max))
460 (org-outdent-item-tree)
461 (should (equal (buffer-string)
463 - Item 1
464 - Item 2
465 - Item 2.1
466 - Item 3
467 - Item 3.1
468 "))))
470 (ert-deftest test-org-list/move-item-down ()
471 "Test `org-move-item-down' specifications."
472 ;; Standard test.
473 (org-test-with-temp-text "- item 1\n- item 2"
474 (org-move-item-down)
475 (should (equal (buffer-string)
476 "- item 2\n- item 1")))
477 ;; Keep same column in item.
478 (org-test-with-temp-text "- item 1\n- item 2"
479 (forward-char 4)
480 (org-move-item-down)
481 (should (looking-at "em 1")))
482 ;; Move sub-items.
483 (org-test-with-temp-text "- item 1\n - sub-item 1\n- item 2"
484 (org-move-item-down)
485 (should (equal (buffer-string)
486 "- item 2\n- item 1\n - sub-item 1")))
487 ;; Preserve blank lines.
488 (should
489 (equal
490 "- item 2\n\n- item 1"
491 (org-test-with-temp-text "- item 1\n\n- item 2"
492 (org-move-item-down)
493 (buffer-string))))
494 ;; Error when trying to move the last item...
495 (org-test-with-temp-text "- item 1\n- item 2"
496 (forward-line)
497 (should-error (org-move-item-down)))
498 ;; ... unless `org-list-use-circular-motion' is non-nil. In this
499 ;; case, move to the first item.
500 (org-test-with-temp-text "- item 1\n- item 2\n- item 3"
501 (forward-line 2)
502 (let ((org-list-use-circular-motion t)) (org-move-item-down))
503 (should (equal (buffer-string) "- item 3\n- item 1\n- item 2\n")))
504 ;; Preserve item visibility.
505 (org-test-with-temp-text "* Headline\n- item 1\n body 1\n- item 2\n body 2"
506 (let ((org-cycle-include-plain-lists t))
507 (search-forward "- item 1")
508 (org-cycle)
509 (search-forward "- item 2")
510 (org-cycle))
511 (search-backward "- item 1")
512 (org-move-item-down)
513 (forward-line)
514 (should (org-invisible-p2))
515 (search-backward " body 2")
516 (should (org-invisible-p2)))
517 ;; Preserve children visibility.
518 (org-test-with-temp-text "* Headline
519 - item 1
520 - sub-item 1
521 sub-body 1
522 - item 2
523 - sub-item 2
524 sub-body 2"
525 (let ((org-cycle-include-plain-lists t))
526 (search-forward "- sub-item 1")
527 (org-cycle)
528 (search-forward "- sub-item 2")
529 (org-cycle))
530 (search-backward "- item 1")
531 (org-move-item-down)
532 (search-forward "sub-body 1")
533 (should (org-invisible-p2))
534 (search-backward "sub-body 2")
535 (should (org-invisible-p2))))
537 (ert-deftest test-org-list/move-item-down-contents-visibility ()
538 "Preserve contents visibility."
539 (org-test-with-temp-text "
540 - item 1
541 #+BEGIN_CENTER
542 Text1
543 #+END_CENTER
544 - item 2
545 #+BEGIN_CENTER
546 Text2
547 #+END_CENTER"
548 (org-hide-block-all)
549 (let ((invisible-property-1
550 (progn
551 (search-forward "Text1")
552 (get-char-property (point) 'invisible)))
553 (invisible-property-2
554 (progn
555 (search-forward "Text2")
556 (get-char-property (point) 'invisible))))
557 (goto-char (point-min))
558 (search-forward "- item 1")
559 (org-move-item-down)
560 (search-forward "Text1")
561 (should (eq invisible-property-1 (get-char-property (point) 'invisible)))
562 (search-backward "Text2")
563 (should (eq invisible-property-2 (get-char-property (point) 'invisible))))))
565 (ert-deftest test-org-list/move-item-up ()
566 "Test `org-move-item-up' specifications."
567 ;; Standard test.
568 (org-test-with-temp-text "- item 1\n- item 2"
569 (forward-line)
570 (org-move-item-up)
571 (should (equal (buffer-string)
572 "- item 2\n- item 1")))
573 ;; Keep same column in item.
574 (org-test-with-temp-text "- item 1\n- item 2"
575 (forward-line)
576 (forward-char 4)
577 (org-move-item-up)
578 (should (looking-at "em 2")))
579 ;; Move sub-items.
580 (org-test-with-temp-text "- item 1\n- item 2\n - sub-item 2"
581 (forward-line)
582 (org-move-item-up)
583 (should (equal (buffer-string)
584 "- item 2\n - sub-item 2\n- item 1")))
585 ;; Preserve blank lines.
586 (should
587 (equal
588 "- item 2\n\n- item 1"
589 (org-test-with-temp-text "- item 1\n\n- item 2"
590 (search-forward "- item 2")
591 (org-move-item-up)
592 (buffer-string))))
593 ;; Error when trying to move the first item...
594 (org-test-with-temp-text "- item 1\n- item 2"
595 (should-error (org-move-item-up)))
596 ;; ... unless `org-list-use-circular-motion' is non-nil. In this
597 ;; case, move to the first item.
598 (org-test-with-temp-text "- item 1\n- item 2\n- item 3"
599 (let ((org-list-use-circular-motion t)) (org-move-item-up))
600 (should (equal (buffer-string) "- item 2\n- item 3\n- item 1")))
601 ;; Preserve item visibility.
602 (org-test-with-temp-text "* Headline\n- item 1\n body 1\n- item 2\n body 2"
603 (let ((org-cycle-include-plain-lists t))
604 (search-forward "- item 1")
605 (org-cycle)
606 (search-forward "- item 2")
607 (org-cycle))
608 (org-move-item-up)
609 (forward-line)
610 (should (org-invisible-p2))
611 (search-forward " body 1")
612 (should (org-invisible-p2)))
613 ;; Preserve children visibility.
614 (org-test-with-temp-text "* Headline
615 - item 1
616 - sub-item 1
617 sub-body 1
618 - item 2
619 - sub-item 2
620 sub-body 2"
621 (let ((org-cycle-include-plain-lists t))
622 (search-forward "- sub-item 1")
623 (org-cycle)
624 (search-forward "- sub-item 2")
625 (org-cycle))
626 (search-backward "- item 2")
627 (org-move-item-up)
628 (search-forward "sub-body 2")
629 (should (org-invisible-p2))
630 (search-forward "sub-body 1")
631 (should (org-invisible-p2))))
633 (ert-deftest test-org-list/move-item-up-contents-visibility ()
634 (org-test-with-temp-text "
635 - item 1
636 #+BEGIN_CENTER
637 Text1
638 #+END_CENTER
639 - item 2
640 #+BEGIN_CENTER
641 Text2
642 #+END_CENTER"
643 (org-hide-block-all)
644 (let ((invisible-property-1
645 (progn
646 (search-forward "Text1")
647 (get-char-property (point) 'invisible)))
648 (invisible-property-2
649 (progn
650 (search-forward "Text2")
651 (get-char-property (point) 'invisible))))
652 (goto-char (point-min))
653 (search-forward "- item 2")
654 (org-move-item-up)
655 (search-forward "Text2")
656 (should (eq invisible-property-2 (get-char-property (point) 'invisible)))
657 (search-forward "Text1")
658 (should (eq invisible-property-1 (get-char-property (point) 'invisible))))))
660 (ert-deftest test-org-list/insert-item ()
661 "Test item insertion."
662 ;; Blank lines specifications.
664 ;; Non-nil `org-blank-before-new-entry': insert a blank line.
665 (should
666 (org-test-with-temp-text "- a"
667 (let ((org-blank-before-new-entry '((plain-list-item . t))))
668 (end-of-line)
669 (org-insert-item)
670 (forward-line -1)
671 (looking-at "$"))))
672 ;; Nil `org-blank-before-new-entry': do not insert a blank line.
673 (should-not
674 (org-test-with-temp-text "- a"
675 (let ((org-blank-before-new-entry '((plain-list-item . nil))))
676 (end-of-line)
677 (org-insert-item)
678 (forward-line -1)
679 (looking-at "$"))))
680 ;; `org-blank-before-new-entry' set to auto: if there's no blank
681 ;; line already in the sole item, do not insert one.
682 (should-not
683 (org-test-with-temp-text "- a"
684 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
685 (end-of-line)
686 (org-insert-item)
687 (forward-line -1)
688 (looking-at "$"))))
689 ;; `org-blank-before-new-entry' set to `auto': if there's a blank
690 ;; line in the sole item, insert another one.
691 (should
692 (org-test-with-temp-text "- a\n\n b<point>"
693 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
694 (org-insert-item)
695 (forward-line -1)
696 (looking-at "$"))))
697 ;; `org-blank-before-new-entry' set to `auto': if the user specified
698 ;; a blank line, preserve it.
699 (should
700 (org-test-with-temp-text "- a\n\n<point>"
701 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
702 (org-insert-item)
703 (forward-line -1)
704 (looking-at "$"))))
705 ;; `org-blank-before-new-entry' set to `auto': if some items in list
706 ;; are already separated by blank lines, insert one.
707 (should
708 (org-test-with-temp-text "- a\n\n- b<point>"
709 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
710 (org-insert-item)
711 (forward-line -1)
712 (looking-at "$"))))
713 (should
714 (org-test-with-temp-text "- a\n\n- b"
715 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
716 (org-insert-item)
717 (forward-line)
718 (looking-at "$"))))
719 (should
720 (org-test-with-temp-text
721 "- a\n #+BEGIN_EXAMPLE\n\n x\n #+END_EXAMPLE<point>"
722 (let ((org-blank-before-new-entry '((plain-list-item . auto))))
723 (org-insert-item)
724 (forward-line -1)
725 (looking-at "$"))))
726 ;; When called before or on the bullet, insert new item before
727 ;; current one.
728 (should
729 (equal "- \n- item"
730 (org-test-with-temp-text "- item"
731 (org-insert-item)
732 (buffer-string))))
733 (should
734 (equal "- \n- item"
735 (org-test-with-temp-text "- <point>item"
736 (org-insert-item)
737 (buffer-string))))
738 ;; When called on tag in a descriptive list, insert new item before
739 ;; current one too.
740 (should
741 (equal "- :: \n- tag :: item"
742 (org-test-with-temp-text "- tag <point>:: item"
743 (org-insert-item)
744 (buffer-string))))
745 (should
746 (equal "- :: \n- tag :: item"
747 (org-test-with-temp-text "- ta<point>g :: item"
748 (org-insert-item)
749 (buffer-string))))
750 ;; Further, it splits the line or add a blank new item after it,
751 ;; according to `org-M-RET-may-split-line'.
752 (should
753 (equal "- it\n- em"
754 (org-test-with-temp-text "- it<point>em"
755 (let ((org-M-RET-may-split-line '((default . t))))
756 (org-insert-item))
757 (buffer-string))))
758 (should
759 (equal "- item\n- "
760 (org-test-with-temp-text "- it<point>em"
761 (let ((org-M-RET-may-split-line '((default . nil))))
762 (org-insert-item))
763 (buffer-string))))
764 ;; Preserve list visibility when inserting an item.
765 (should
766 (equal
767 '(outline outline)
768 (org-test-with-temp-text "- A\n - B\n- C\n - D"
769 (let ((org-cycle-include-plain-lists t))
770 (org-cycle)
771 (forward-line 2)
772 (org-cycle)
773 (org-insert-item)
774 (list (get-char-property (line-beginning-position 0) 'invisible)
775 (get-char-property (line-end-position 2) 'invisible)))))))
777 (ert-deftest test-org-list/repair ()
778 "Test `org-list-repair' specifications."
779 ;; Repair indentation.
780 (should
781 (equal "- item\n - child"
782 (org-test-with-temp-text "- item\n - child"
783 (let ((org-list-indent-offset 0)) (org-list-repair))
784 (buffer-string))))
785 ;; Repair bullets and numbering.
786 (should
787 (equal "- a\n- b"
788 (org-test-with-temp-text "- a\n+ b"
789 (let ((org-list-indent-offset 0))
790 (org-list-repair))
791 (buffer-string))))
792 (should
793 (equal "1. a\n2. b"
794 (org-test-with-temp-text "1. a\n1. b"
795 (let ((org-list-indent-offset 0)
796 (org-plain-list-ordered-item-terminator t))
797 (org-list-repair))
798 (buffer-string))))
799 ;; Repair check-boxes.
800 (should
801 (equal "- [X] item\n - [X] child"
802 (org-test-with-temp-text "- [ ] item\n - [X] child"
803 (let ((org-list-indent-offset 0))
804 (org-list-repair))
805 (buffer-string))))
806 ;; Special case: do not move contents of an item within its child.
807 ;; Yet, preserve indentation differences within contents.
808 (should
809 (equal "- item\n - child\n within item"
810 (org-test-with-temp-text "- item\n - child\n within item"
811 (let ((org-list-indent-offset 0)) (org-list-repair))
812 (buffer-string))))
813 (should
814 (equal
815 "- item\n - child\n within item\n indented"
816 (org-test-with-temp-text
817 "- item\n - child\n within item\n indented"
818 (let ((org-list-indent-offset 0)) (org-list-repair))
819 (buffer-string)))))
821 (ert-deftest test-org-list/update-checkbox-count ()
822 "Test `org-update-checkbox-count' specifications."
823 ;; From a headline.
824 (should
825 (string-match "\\[0/1\\]"
826 (org-test-with-temp-text "* [/]\n- [ ] item"
827 (org-update-checkbox-count)
828 (buffer-string))))
829 (should
830 (string-match "\\[1/1\\]"
831 (org-test-with-temp-text "* [/]\n- [X] item"
832 (org-update-checkbox-count)
833 (buffer-string))))
834 (should
835 (string-match "\\[100%\\]"
836 (org-test-with-temp-text "* [%]\n- [X] item"
837 (org-update-checkbox-count)
838 (buffer-string))))
839 ;; From a list or a sub-list.
840 (should
841 (string-match "\\[0/1\\]"
842 (org-test-with-temp-text "- [/]\n - [ ] item"
843 (org-update-checkbox-count)
844 (buffer-string))))
845 (should
846 (string-match "\\[1/1\\]"
847 (org-test-with-temp-text "- [/]\n - [X] item"
848 (org-update-checkbox-count)
849 (buffer-string))))
850 (should
851 (string-match "\\[100%\\]"
852 (org-test-with-temp-text "- [%]\n - [X] item"
853 (org-update-checkbox-count)
854 (buffer-string))))
855 (should
856 (string-match
857 "\\[1/1\\]"
858 (org-test-with-temp-text "- [ ] item 1\n- [ ] item 2 [/]\n - [X] sub 1"
859 (org-update-checkbox-count)
860 (buffer-string))))
861 ;; Count do not apply to sub-lists unless count is not hierarchical.
862 ;; This state can be achieved with COOKIE_DATA node property set to
863 ;; "recursive".
864 (should
865 (string-match "\\[1/1\\]"
866 (org-test-with-temp-text "- [/]\n - item\n - [X] sub-item"
867 (let ((org-checkbox-hierarchical-statistics nil))
868 (org-update-checkbox-count))
869 (buffer-string))))
870 (should
871 (string-match "\\[1/1\\]"
872 (org-test-with-temp-text "
873 <point>* H
874 :PROPERTIES:
875 :COOKIE_DATA: recursive
876 :END:
877 - [/]
878 - item
879 - [X] sub-item"
880 (org-update-checkbox-count)
881 (buffer-string))))
882 (should
883 (string-match "\\[0/0\\]"
884 (org-test-with-temp-text "- [/]\n - item\n - [ ] sub-item"
885 (org-update-checkbox-count)
886 (buffer-string))))
887 ;; With optional argument ALL, update all buffer.
888 (should
889 (= 2
890 (org-test-with-temp-text "* [/]\n- [X] item\n* [/]\n- [X] item"
891 (org-update-checkbox-count t)
892 (count-matches "\\[1/1\\]"))))
893 ;; Ignore boxes in drawers, blocks or inlinetasks when counting from
894 ;; outside.
895 (should
896 (string-match "\\[2/2\\]"
897 (org-test-with-temp-text "
898 - [/]
899 - [X] item1
900 :DRAWER:
901 - [X] item
902 :END:
903 - [X] item2"
904 (let ((org-checkbox-hierarchical-statistics nil))
905 (org-update-checkbox-count))
906 (buffer-string)))))
910 ;;; Miscellaneous
912 (ert-deftest test-org-list/toggle-item ()
913 "Test `org-toggle-item' specifications."
914 ;; Convert normal lines to items.
915 (should
916 (equal "- line"
917 (org-test-with-temp-text "line"
918 (org-toggle-item nil)
919 (buffer-string))))
920 ;; Convert items to normal lines.
921 (should
922 (equal "line"
923 (org-test-with-temp-text "- line"
924 (org-toggle-item nil)
925 (buffer-string))))
926 ;; Convert headlines to items.
927 (should
928 (equal "- line"
929 (org-test-with-temp-text "* line"
930 (org-toggle-item nil)
931 (buffer-string))))
932 ;; When converting a headline to a list item, TODO keywords become
933 ;; checkboxes.
934 (should
935 (equal "- [X] line"
936 (org-test-with-temp-text "* DONE line"
937 (org-toggle-item nil)
938 (buffer-string))))
939 (should
940 (equal "- [ ] line"
941 (org-test-with-temp-text "* TODO line"
942 (org-toggle-item nil)
943 (buffer-string))))
944 ;; When turning headlines into items, make sure planning info line
945 ;; and properties drawers are removed. This also includes empty
946 ;; lines following them.
947 (should
948 (equal "- H\n"
949 (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29 Thu>"
950 (org-toggle-item nil)
951 (buffer-string))))
952 (should
953 (equal "- H\n"
954 (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:"
955 (org-toggle-item nil)
956 (buffer-string))))
957 (should
958 (equal "- H\nText"
959 (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n\n\nText"
960 (org-toggle-item nil)
961 (buffer-string))))
962 ;; When a region is marked and first line is a headline, all
963 ;; headlines are turned into items.
964 (should
965 (equal "- H1\n - H2"
966 (org-test-with-temp-text "* H1\n** H2"
967 (transient-mark-mode 1)
968 (push-mark (point) t t)
969 (goto-char (point-max))
970 (org-toggle-item nil)
971 (buffer-string))))
972 (should
973 (equal "- [ ] H1\n - [ ] H2"
974 (org-test-with-temp-text "* TODO H1\n** TODO H2"
975 (transient-mark-mode 1)
976 (push-mark (point) t t)
977 (goto-char (point-max))
978 (org-toggle-item nil)
979 (buffer-string))))
980 ;; When turning headlines into items, make sure headings contents
981 ;; are kept within items.
982 (should
983 (equal "- H1\n Text"
984 (org-test-with-temp-text "* H1\nText"
985 (transient-mark-mode 1)
986 (push-mark (point) t t)
987 (goto-char (point-max))
988 (org-toggle-item nil)
989 (buffer-string))))
990 ;; When a region is marked and first line is an item, all items are
991 ;; turned into normal lines.
992 (should
993 (equal "1\n 2"
994 (org-test-with-temp-text "- 1\n - 2"
995 (transient-mark-mode 1)
996 (push-mark (point) t t)
997 (goto-char (point-max))
998 (org-toggle-item nil)
999 (buffer-string))))
1000 (should
1001 (equal "1\n2"
1002 (org-test-with-temp-text "- 1\n2"
1003 (transient-mark-mode 1)
1004 (push-mark (point) t t)
1005 (goto-char (point-max))
1006 (org-toggle-item nil)
1007 (buffer-string))))
1008 ;; When a region is marked and first line is an item, all normal
1009 ;; lines are turned into items.
1010 (should
1011 (equal "- line 1\n- line 2"
1012 (org-test-with-temp-text "line 1\nline 2"
1013 (transient-mark-mode 1)
1014 (push-mark (point) t t)
1015 (goto-char (point-max))
1016 (org-toggle-item nil)
1017 (buffer-string))))
1018 (should
1019 (equal "- line 1\n- line 2"
1020 (org-test-with-temp-text "line 1\n- line 2"
1021 (transient-mark-mode 1)
1022 (push-mark (point) t t)
1023 (goto-char (point-max))
1024 (org-toggle-item nil)
1025 (buffer-string))))
1026 ;; When argument ARG is non-nil, change the whole region into
1027 ;; a single item.
1028 (should
1029 (equal "- line 1\n line 2"
1030 (org-test-with-temp-text "line 1\nline 2"
1031 (transient-mark-mode 1)
1032 (push-mark (point) t t)
1033 (goto-char (point-max))
1034 (org-toggle-item t)
1035 (buffer-string)))))
1037 (ert-deftest test-org-list/sort ()
1038 "Test `org-sort-list'."
1039 ;; Sort alphabetically.
1040 (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
1041 (cl-letf (((symbol-function 'string-collate-lessp)
1042 (lambda (s1 s2 &optional locale ignore-case)
1043 (funcall original-string-collate-lessp
1044 s1 s2 "C" ignore-case))))
1045 (should
1046 (equal "- abc\n- def\n- XYZ\n"
1047 (org-test-with-temp-text "- def\n- XYZ\n- abc\n"
1048 (org-sort-list nil ?a)
1049 (buffer-string))))
1050 (should
1051 (equal "- XYZ\n- def\n- abc\n"
1052 (org-test-with-temp-text "- def\n- XYZ\n- abc\n"
1053 (org-sort-list nil ?A)
1054 (buffer-string))))
1055 ;; Sort alphabetically (with case).
1056 (should
1057 (equal "- C\n- a\n- b\n"
1058 (org-test-with-temp-text "- b\n- C\n- a\n"
1059 (org-sort-list t ?a)
1060 (buffer-string))))
1061 (should
1062 (equal "- b\n- a\n- C\n"
1063 (org-test-with-temp-text "- b\n- C\n- a\n"
1064 (org-sort-list t ?A)
1065 (buffer-string))))))
1066 ;; Sort numerically.
1067 (should
1068 (equal "- 1\n- 2\n- 10\n"
1069 (org-test-with-temp-text "- 10\n- 1\n- 2\n"
1070 (org-sort-list nil ?n)
1071 (buffer-string))))
1072 (should
1073 (equal "- 10\n- 2\n- 1\n"
1074 (org-test-with-temp-text "- 10\n- 1\n- 2\n"
1075 (org-sort-list nil ?N)
1076 (buffer-string))))
1077 ;; Sort by checked status.
1078 (should
1079 (equal "- [ ] xyz\n- [ ] def\n- [X] abc\n"
1080 (org-test-with-temp-text "- [X] abc\n- [ ] xyz\n- [ ] def\n"
1081 (org-sort-list nil ?x)
1082 (buffer-string))))
1083 (should
1084 (equal "- [X] abc\n- [ ] xyz\n- [ ] def\n"
1085 (org-test-with-temp-text "- [X] abc\n- [ ] xyz\n- [ ] def\n"
1086 (org-sort-list nil ?X)
1087 (buffer-string))))
1088 ;; Sort by time stamp.
1089 (should
1090 (equal "- <2017-05-08 Mon>\n- <2017-05-09 Tue>\n- <2018-05-09 Wed>\n"
1091 (org-test-with-temp-text
1092 "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
1093 (org-sort-list nil ?t)
1094 (buffer-string))))
1095 (should
1096 (equal "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
1097 (org-test-with-temp-text
1098 "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
1099 (org-sort-list nil ?T)
1100 (buffer-string))))
1101 ;; Sort by custom function.
1102 (should
1103 (equal "- b\n- aa\n- ccc\n"
1104 (org-test-with-temp-text "- ccc\n- b\n- aa\n"
1105 (org-sort-list nil ?f
1106 (lambda ()
1107 (length (buffer-substring (point-at-bol)
1108 (point-at-eol))))
1109 #'<)
1110 (buffer-string))))
1111 (should
1112 (equal "- ccc\n- aa\n- b\n"
1113 (org-test-with-temp-text "- ccc\n- b\n- aa\n"
1114 (org-sort-list nil ?F
1115 (lambda ()
1116 (length (buffer-substring (point-at-bol)
1117 (point-at-eol))))
1118 #'<)
1119 (buffer-string)))))
1122 ;;; List transformations
1124 (ert-deftest test-org-list/to-generic ()
1125 "Test `org-list-to-generic' specifications."
1126 ;; Test `:ustart' and `:uend' parameters.
1127 (should
1128 (equal
1129 "begin\na"
1130 (org-test-with-temp-text "- a"
1131 (org-list-to-generic (org-list-to-lisp) '(:ustart "begin")))))
1132 (should-not
1133 (equal
1134 "begin\na"
1135 (org-test-with-temp-text "1. a"
1136 (org-list-to-generic (org-list-to-lisp) '(:ustart "begin")))))
1137 (should
1138 (equal
1139 "a\nend"
1140 (org-test-with-temp-text "- a"
1141 (org-list-to-generic (org-list-to-lisp) '(:uend "end")))))
1142 (should-not
1143 (equal
1144 "a\nend"
1145 (org-test-with-temp-text "1. a"
1146 (org-list-to-generic (org-list-to-lisp) '(:uend "end")))))
1147 (should
1148 (equal
1149 "begin l1\na\nbegin l2\nb\nend l2\nend l1"
1150 (org-test-with-temp-text "- a\n - b"
1151 (org-list-to-generic
1152 (org-list-to-lisp)
1153 (list :ustart (lambda (l) (format "begin l%d" l))
1154 :uend (lambda (l) (format "end l%d" l)))))))
1155 ;; Test `:ostart' and `:oend' parameters.
1156 (should
1157 (equal
1158 "begin\na"
1159 (org-test-with-temp-text "1. a"
1160 (org-list-to-generic (org-list-to-lisp) '(:ostart "begin")))))
1161 (should-not
1162 (equal
1163 "begin\na"
1164 (org-test-with-temp-text "- a"
1165 (org-list-to-generic (org-list-to-lisp) '(:ostart "begin")))))
1166 (should
1167 (equal
1168 "a\nend"
1169 (org-test-with-temp-text "1. a"
1170 (org-list-to-generic (org-list-to-lisp) '(:oend "end")))))
1171 (should-not
1172 (equal
1173 "a\nend"
1174 (org-test-with-temp-text "- a"
1175 (org-list-to-generic (org-list-to-lisp) '(:oend "end")))))
1176 (should
1177 (equal
1178 "begin l1\na\nbegin l2\nb\nend l2\nend l1"
1179 (org-test-with-temp-text "1. a\n 1. b"
1180 (org-list-to-generic
1181 (org-list-to-lisp)
1182 (list :ostart (lambda (l) (format "begin l%d" l))
1183 :oend (lambda (l) (format "end l%d" l)))))))
1184 ;; Test `:dstart' and `:dend' parameters.
1185 (should
1186 (equal
1187 "begin\ntaga"
1188 (org-test-with-temp-text "- tag :: a"
1189 (org-list-to-generic (org-list-to-lisp) '(:dstart "begin")))))
1190 (should-not
1191 (equal
1192 "begin\na"
1193 (org-test-with-temp-text "- a"
1194 (org-list-to-generic (org-list-to-lisp) '(:dstart "begin")))))
1195 (should
1196 (equal
1197 "taga\nend"
1198 (org-test-with-temp-text "- tag :: a"
1199 (org-list-to-generic (org-list-to-lisp) '(:dend "end")))))
1200 (should-not
1201 (equal
1202 "a\nend"
1203 (org-test-with-temp-text "- a"
1204 (org-list-to-generic (org-list-to-lisp) '(:dend "end")))))
1205 (should
1206 (equal
1207 "begin l1\ntag1a\nbegin l2\ntag2b\nend l2\nend l1"
1208 (org-test-with-temp-text "- tag1 :: a\n - tag2 :: b"
1209 (org-list-to-generic
1210 (org-list-to-lisp)
1211 (list :dstart (lambda (l) (format "begin l%d" l))
1212 :dend (lambda (l) (format "end l%d" l)))))))
1213 ;; Test `:dtstart', `:dtend', `:ddstart' and `:ddend' parameters.
1214 (should
1215 (equal
1216 ">tag<a"
1217 (org-test-with-temp-text "- tag :: a"
1218 (org-list-to-generic (org-list-to-lisp) '(:dtstart ">" :dtend "<")))))
1219 (should
1220 (equal
1221 "tag>a<"
1222 (org-test-with-temp-text "- tag :: a"
1223 (org-list-to-generic (org-list-to-lisp) '(:ddstart ">" :ddend "<")))))
1224 ;; Test `:istart' and `:iend' parameters.
1225 (should
1226 (equal
1227 "starta"
1228 (org-test-with-temp-text "- a"
1229 (org-list-to-generic (org-list-to-lisp) '(:istart "start")))))
1230 (should
1231 (equal
1232 "level1 a\nlevel2 b"
1233 (org-test-with-temp-text "- a\n - b"
1234 (org-list-to-generic (org-list-to-lisp)
1235 '(:istart (lambda (type l) (format "level%d "l)))))))
1236 (should
1237 (equal
1238 "a\nblevel2level1"
1239 (org-test-with-temp-text "- a\n - b"
1240 (org-list-to-generic (org-list-to-lisp)
1241 '(:iend (lambda (type l) (format "level%d" l)))))))
1242 ;; Test `:icount' parameter.
1243 (should
1244 (equal
1245 "counta"
1246 (org-test-with-temp-text "1. [@3] a"
1247 (org-list-to-generic (org-list-to-lisp) '(:icount "count")))))
1248 (should-not
1249 (equal
1250 "counta"
1251 (org-test-with-temp-text "1. a"
1252 (org-list-to-generic (org-list-to-lisp) '(:icount "count")))))
1253 (should
1254 (equal
1255 "counta"
1256 (org-test-with-temp-text "1. [@3] a"
1257 (org-list-to-generic (org-list-to-lisp)
1258 '(:icount "count" :istart "start")))))
1259 (should
1260 (equal
1261 "level:1, counter:3 a"
1262 (org-test-with-temp-text "1. [@3] a"
1263 (org-list-to-generic
1264 (org-list-to-lisp)
1265 '(:icount (lambda (type l c) (format "level:%d, counter:%d " l c)))))))
1266 ;; Test `:isep' parameter.
1267 (should
1268 (equal
1269 "a\n--\nb"
1270 (org-test-with-temp-text "- a\n- b"
1271 (org-list-to-generic (org-list-to-lisp) '(:isep "--")))))
1272 (should-not
1273 (equal
1274 "a\n--\nb"
1275 (org-test-with-temp-text "- a\n - b"
1276 (org-list-to-generic (org-list-to-lisp) '(:isep "--")))))
1277 (should
1278 (equal
1279 "a\n- 1 -\nb"
1280 (org-test-with-temp-text "- a\n- b"
1281 (org-list-to-generic
1282 (org-list-to-lisp)
1283 '(:isep (lambda (type depth) (format "- %d -" depth)))))))
1284 ;; Test `:ifmt' parameter.
1285 (should
1286 (equal
1287 ">> a <<"
1288 (org-test-with-temp-text "1. [@3] a"
1289 (org-list-to-generic
1290 (org-list-to-lisp)
1291 '(:ifmt (lambda (type c) (format ">> %s <<" c)))))))
1292 ;; Test `:cbon', `:cboff', `:cbtrans'
1293 (should
1294 (equal
1295 "!a"
1296 (org-test-with-temp-text "- [X] a"
1297 (org-list-to-generic (org-list-to-lisp) '(:cbon "!")))))
1298 (should-not
1299 (equal
1300 "!a"
1301 (org-test-with-temp-text "- [X] a"
1302 (org-list-to-generic (org-list-to-lisp) '(:cboff "!" :cbtrans "!")))))
1303 (should
1304 (equal
1305 "!a"
1306 (org-test-with-temp-text "- [ ] a"
1307 (org-list-to-generic (org-list-to-lisp) '(:cboff "!")))))
1308 (should-not
1309 (equal
1310 "!a"
1311 (org-test-with-temp-text "- [ ] a"
1312 (org-list-to-generic (org-list-to-lisp) '(:cbon "!" :cbtrans "!")))))
1313 (should
1314 (equal
1315 "!a"
1316 (org-test-with-temp-text "- [-] a"
1317 (org-list-to-generic (org-list-to-lisp) '(:cbtrans "!")))))
1318 (should-not
1319 (equal
1320 "!a"
1321 (org-test-with-temp-text "- [-] a"
1322 (org-list-to-generic (org-list-to-lisp) '(:cbon "!" :cboff "!")))))
1323 ;; Test `:splice' parameter.
1324 (should
1325 (equal
1327 (org-test-with-temp-text "- a"
1328 (org-list-to-generic (org-list-to-lisp)
1329 '(:ustart "begin" :uend "end" :splice t)))))
1330 ;; No error on empty lists.
1331 (should
1332 (org-test-with-temp-text "-" (org-list-to-generic (org-list-to-lisp) nil))))
1334 (ert-deftest test-org-list/to-html ()
1335 "Test `org-list-to-html' specifications."
1336 (should
1337 (equal "<ul class=\"org-ul\">\n<li>a</li>\n</ul>"
1338 (org-test-with-temp-text "- a"
1339 (org-list-to-html (org-list-to-lisp) nil)))))
1341 (ert-deftest test-org-list/to-latex ()
1342 "Test `org-list-to-latex' specifications."
1343 (should
1344 (equal "\\begin{itemize}\n\\item a\n\\end{itemize}"
1345 (org-test-with-temp-text "- a"
1346 (org-list-to-latex (org-list-to-lisp) nil)))))
1348 (ert-deftest test-org-list/to-texinfo ()
1349 "Test `org-list-to-texinfo' specifications."
1350 (should
1351 (equal "@itemize\n@item\na\n@end itemize"
1352 (org-test-with-temp-text "- a"
1353 (org-list-to-texinfo (org-list-to-lisp) nil)))))
1355 (ert-deftest test-org-list/to-org ()
1356 "Test `org-list-to-org' specifications."
1357 ;; Un-ordered list.
1358 (should
1359 (equal "- a"
1360 (org-test-with-temp-text "- a"
1361 (org-list-to-org (org-list-to-lisp) nil))))
1362 ;; Ordered list.
1363 (should
1364 (equal "1. a"
1365 (org-test-with-temp-text "1. a"
1366 (org-list-to-org (org-list-to-lisp) nil))))
1367 ;; Descriptive list.
1368 (should
1369 (equal "- a :: b"
1370 (org-test-with-temp-text "- a :: b"
1371 (org-list-to-org (org-list-to-lisp) nil))))
1372 ;; Nested list.
1373 (should
1374 (equal "- a\n - b"
1375 (org-test-with-temp-text "- a\n - b"
1376 (org-list-to-org (org-list-to-lisp) nil))))
1377 ;; Item spanning over multiple lines.
1378 (should
1379 (equal "- a\n b"
1380 (org-test-with-temp-text "- a\n b"
1381 (org-list-to-org (org-list-to-lisp) nil))))
1382 ;; Item with continuation text after a sub-list.
1383 (should
1384 (equal "- a\n - b\n c"
1385 (org-test-with-temp-text "- a\n - b\n c"
1386 (org-list-to-org (org-list-to-lisp) nil)))))
1389 (provide 'test-org-list)
1390 ;;; test-org-list.el ends here