test-org-inlinetask.el 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. ;;; test-org-inlinetask.el --- Tests for org-inlinetask.el -*- lexical-binding: t; -*-
  2. ;; Copyright (c) Marco Wahl
  3. ;; Authors: Marco Wahl
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ;;; Comments:
  15. ;; Tests for org-inlinetask.el.
  16. ;;; Code:
  17. (require 'org-inlinetask)
  18. ;;; Test movement
  19. (ert-deftest test-org-inlinetask/org-inlinetask-goto-end ()
  20. ;; Goto end.
  21. (should
  22. (equal
  23. (let ((org-inlinetask-min-level 5)
  24. (org-adapt-indentation t))
  25. (org-test-with-temp-text
  26. "** H
  27. <point>***** I
  28. ***** END
  29. foo"
  30. (org-inlinetask-goto-end)
  31. (insert "<point>")
  32. (buffer-string)))
  33. "** H
  34. ***** I
  35. ***** END
  36. <point>foo"))
  37. ;; Goto end. End is buffer end.
  38. (should
  39. (equal
  40. (let ((org-inlinetask-min-level 5)
  41. (org-adapt-indentation t))
  42. (org-test-with-temp-text
  43. "** H
  44. <point>***** I
  45. ***** END"
  46. (org-inlinetask-goto-end)
  47. (insert "<point>")
  48. (buffer-string)))
  49. "** H
  50. ***** I
  51. ***** END<point>"))
  52. ;; Goto end. Starting somewhere.
  53. (should
  54. (equal
  55. (let ((org-inlinetask-min-level 5)
  56. (org-adapt-indentation t))
  57. (org-test-with-temp-text
  58. "** H
  59. ****<point>* I
  60. ***** END
  61. ***** I
  62. ***** END"
  63. (org-inlinetask-goto-end)
  64. (insert "<point>")
  65. (buffer-string)))
  66. "** H
  67. ***** I
  68. ***** END
  69. <point>***** I
  70. ***** END"))
  71. (should
  72. (equal
  73. (let ((org-inlinetask-min-level 5)
  74. (org-adapt-indentation t))
  75. (org-test-with-temp-text
  76. "** H
  77. ***** I
  78. <point> inside
  79. ***** END
  80. ***** I
  81. ***** END"
  82. (org-inlinetask-goto-end)
  83. (insert "<point>")
  84. (buffer-string)))
  85. "** H
  86. ***** I
  87. inside
  88. ***** END
  89. <point>***** I
  90. ***** END")))
  91. (ert-deftest test-org-inlinetask/inlinetask-within-plain-list ()
  92. "Fold inlinetasks in plain-lists.
  93. Report:
  94. http://lists.gnu.org/archive/html/emacs-orgmode/2017-12/msg00502.html"
  95. (should
  96. (org-test-with-temp-text
  97. "* Test
  98. <point>- x
  99. - a
  100. *************** List folding stopped here
  101. *************** END
  102. - b
  103. "
  104. (org-cycle-internal-local)
  105. (invisible-p (1- (search-forward "- b"))))))
  106. (ert-deftest test-org-inlinetask/folding-directly-consecutive-tasks/0 ()
  107. "Fold directly consecutive inlinetasks."
  108. (should
  109. (org-test-with-temp-text
  110. "* Test
  111. <point>- x
  112. - a
  113. *************** List folding stopped here
  114. *************** END
  115. *************** List folding stopped here
  116. *************** END
  117. - b
  118. "
  119. (org-cycle-internal-local)
  120. (invisible-p (1- (search-forward "- b"))))))
  121. (ert-deftest test-org-inlinetask/folding-directly-consecutive-tasks/1 ()
  122. "Fold directly consecutive inlinetasks."
  123. (should
  124. (org-test-with-temp-text
  125. "<point>* Test
  126. *************** p1
  127. p2
  128. *************** END
  129. *************** p3
  130. p4
  131. *************** END
  132. "
  133. (org-flag-subtree t)
  134. (org-cycle)
  135. (and
  136. (not (invisible-p (1- (search-forward "p1"))))
  137. (invisible-p (1- (search-forward "p2")))
  138. (not (invisible-p (1- (search-forward "p3"))))
  139. (invisible-p (1- (search-forward "p4")))))))
  140. (provide 'test-org-inlinetask)
  141. ;;; test-org-inlinetask.el ends here