[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 6d4e65a124 20/44: Add org-fold-related tests
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 6d4e65a124 20/44: Add org-fold-related tests |
Date: |
Mon, 25 Apr 2022 07:57:57 -0400 (EDT) |
branch: externals/org
commit 6d4e65a1249ae8dce754174ffea4342e6454cb30
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
Add org-fold-related tests
---
testing/lisp/test-ol.el | 24 ++++++
testing/lisp/test-org-list.el | 73 ++++++++++++-----
testing/lisp/test-org.el | 177 ++++++++++++++++++++++++++++++++++++++----
3 files changed, 238 insertions(+), 36 deletions(-)
diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el
index ddcc570b3e..343631623b 100644
--- a/testing/lisp/test-ol.el
+++ b/testing/lisp/test-ol.el
@@ -50,6 +50,30 @@
(org-link-encode "http://some.host.com/form?&id=blah%2Bblah25"
'(?\s ?\[ ?\] ?%))))))
+(ert-deftest test-ol/org-toggle-link-display ()
+ "Make sure that `org-toggle-link-display' is working.
+See https://github.com/yantar92/org/issues/4."
+ (dolist (org-link-descriptive '(nil t))
+ (org-test-with-temp-text "* Org link test
+[[https://example.com][A link to a site]]"
+ (dotimes (_ 2)
+ (goto-char 1)
+ (re-search-forward "\\[")
+ (should-not (xor org-link-descriptive (org-invisible-p)))
+ (re-search-forward "example")
+ (should-not (xor org-link-descriptive (org-invisible-p)))
+ (re-search-forward "com")
+ (should-not (xor org-link-descriptive (org-invisible-p)))
+ (re-search-forward "]")
+ (should-not (xor org-link-descriptive (org-invisible-p)))
+ (re-search-forward "\\[")
+ (should-not (org-invisible-p))
+ (re-search-forward "link")
+ (should-not (org-invisible-p))
+ (re-search-forward "]")
+ (should-not (xor org-link-descriptive (org-invisible-p)))
+ (org-toggle-link-display)))))
+
;;; Escape and Unescape Links
diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el
index a9490692ea..bc8faa6728 100644
--- a/testing/lisp/test-org-list.el
+++ b/testing/lisp/test-org-list.el
@@ -580,22 +580,40 @@ b. Item 2<point>"
(let ((org-list-use-circular-motion t)) (org-move-item-down))
(buffer-string))))
;; Preserve item visibility.
+ (should
+ (equal
+ (make-list 2 'org-fold-outline)
+ (let ((org-fold-core-style 'text-properties))
+ (org-test-with-temp-text
+ "* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
+ (let ((org-cycle-include-plain-lists t))
+ (org-cycle)
+ (search-forward "- item 2")
+ (org-cycle))
+ (search-backward "- item 1")
+ (org-move-item-down)
+ (forward-line)
+ (list (org-fold-get-folding-spec)
+ (progn
+ (search-backward " body 2")
+ (org-fold-get-folding-spec)))))))
(should
(equal
'(outline outline)
- (org-test-with-temp-text
- "* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
- (let ((org-cycle-include-plain-lists t))
- (org-cycle)
- (search-forward "- item 2")
- (org-cycle))
- (search-backward "- item 1")
- (org-move-item-down)
- (forward-line)
- (list (org-invisible-p2)
- (progn
- (search-backward " body 2")
- (org-invisible-p2))))))
+ (let ((org-fold-core-style 'overlays))
+ (org-test-with-temp-text
+ "* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
+ (let ((org-cycle-include-plain-lists t))
+ (org-cycle)
+ (search-forward "- item 2")
+ (org-cycle))
+ (search-backward "- item 1")
+ (org-move-item-down)
+ (forward-line)
+ (list (org-invisible-p2)
+ (progn
+ (search-backward " body 2")
+ (org-invisible-p2)))))))
;; Preserve children visibility.
(org-test-with-temp-text "* Headline
- item 1
@@ -869,17 +887,30 @@ b. Item 2<point>"
(org-insert-item)
(buffer-string))))
;; Preserve list visibility when inserting an item.
+ (should
+ (equal
+ `(org-fold-outline org-fold-outline)
+ (let ((org-fold-core-style 'text-properties))
+ (org-test-with-temp-text "- A\n - B\n- C\n - D"
+ (let ((org-cycle-include-plain-lists t))
+ (org-cycle)
+ (forward-line 2)
+ (org-cycle)
+ (org-insert-item)
+ (list (org-fold-get-folding-spec nil
(line-beginning-position 0))
+ (org-fold-get-folding-spec nil
(line-end-position 2))))))))
(should
(equal
'(outline outline)
- (org-test-with-temp-text "- A\n - B\n- C\n - D"
- (let ((org-cycle-include-plain-lists t))
- (org-cycle)
- (forward-line 2)
- (org-cycle)
- (org-insert-item)
- (list (get-char-property (line-beginning-position 0) 'invisible)
- (get-char-property (line-end-position 2) 'invisible))))))
+ (let ((org-fold-core-style 'overlays))
+ (org-test-with-temp-text "- A\n - B\n- C\n - D"
+ (let ((org-cycle-include-plain-lists t))
+ (org-cycle)
+ (forward-line 2)
+ (org-cycle)
+ (org-insert-item)
+ (list (get-char-property
(line-beginning-position 0) 'invisible)
+ (get-char-property (line-end-position 2)
'invisible)))))))
;; Test insertion in area after a sub-list. In particular, if point
;; is right at the end of the previous sub-list, still insert
;; a sub-item in that list.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 0cc8df1543..ca0dc676b0 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -4462,7 +4462,9 @@ Outside."
;; Preserve visibility of elements and their contents.
(should
(equal '((63 . 82) (26 . 48))
- (org-test-with-temp-text "
+ (let ((org-fold-core-style 'text-properties))
+ (org-test-with-temp-text
+ "
#+BEGIN_CENTER
Text.
#+END_CENTER
@@ -4470,11 +4472,35 @@ Text.
#+BEGIN_QUOTE
Text.
#+END_QUOTE"
- (while (search-forward "BEGIN_" nil t) (org-cycle))
- (search-backward "- item 1")
- (org-drag-element-backward)
- (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
- (overlays-in (point-min) (point-max))))))
+ (while (search-forward "BEGIN_" nil t) (org-cycle))
+ (search-backward "- item 1")
+ (org-drag-element-backward)
+ (let (regions)
+ (goto-char (point-min))
+ (while (< (point) (point-max))
+ (let ((region (org-fold-get-region-at-point)))
+ (if (not region)
+ (goto-char (org-fold-next-folding-state-change))
+ (goto-char (cdr region))
+ (push region regions))))
+ regions)))))
+ (should
+ (equal '((63 . 82) (26 . 48))
+ (let ((org-fold-core-style 'overlays))
+ (org-test-with-temp-text
+ "
+#+BEGIN_CENTER
+Text.
+#+END_CENTER
+- item 1
+ #+BEGIN_QUOTE
+ Text.
+ #+END_QUOTE"
+ (while (search-forward "BEGIN_" nil t) (org-cycle))
+ (search-backward "- item 1")
+ (org-drag-element-backward)
+ (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
+ (overlays-in (point-min) (point-max)))))))
;; Pathological case: handle call with point in blank lines right
;; after a headline.
(should
@@ -4511,7 +4537,9 @@ Text.
(should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
(should (looking-at " 1")))
;; 5. Preserve visibility of elements and their contents.
- (org-test-with-temp-text "
+ (let ((org-fold-core-style 'text-properties))
+ (org-test-with-temp-text
+ "
#+BEGIN_CENTER
Text.
#+END_CENTER
@@ -4519,14 +4547,39 @@ Text.
#+BEGIN_QUOTE
Text.
#+END_QUOTE"
- (while (search-forward "BEGIN_" nil t) (org-cycle))
- (search-backward "#+BEGIN_CENTER")
- (org-drag-element-forward)
- (should
- (equal
- '((63 . 82) (26 . 48))
- (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
- (overlays-in (point-min) (point-max)))))))
+ (while (search-forward "BEGIN_" nil t) (org-cycle))
+ (search-backward "#+BEGIN_CENTER")
+ (org-drag-element-forward)
+ (should
+ (equal
+ '((63 . 82) (26 . 48))
+ (let (regions)
+ (goto-char (point-min))
+ (while (< (point) (point-max))
+ (let ((region (org-fold-get-region-at-point)))
+ (if (not region)
+ (goto-char (org-fold-next-folding-state-change))
+ (goto-char (cdr region))
+ (push region regions))))
+ regions)))))
+ (let ((org-fold-core-style 'overlays))
+ (org-test-with-temp-text
+ "
+#+BEGIN_CENTER
+Text.
+#+END_CENTER
+- item 1
+ #+BEGIN_QUOTE
+ Text.
+ #+END_QUOTE"
+ (while (search-forward "BEGIN_" nil t) (org-cycle))
+ (search-backward "#+BEGIN_CENTER")
+ (org-drag-element-forward)
+ (should
+ (equal
+ '((63 . 82) (26 . 48))
+ (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
+ (overlays-in (point-min) (point-max))))))))
(ert-deftest test-org/next-block ()
"Test `org-next-block' specifications."
@@ -8419,6 +8472,100 @@ Contents
(org-kill-note-or-show-branches)
(should (org-invisible-p (- (point-max) 2)))))
+(ert-deftest test-org/org-cycle-narrowed-subtree ()
+ "Test cycling in narrowed buffer."
+ (org-test-with-temp-text
+ "* Heading 1<point>
+** Child 1.1
+** Child 1.2
+some text
+*** Sub-child 1.2.1
+* Heading 2"
+ (org-overview)
+ (org-narrow-to-subtree)
+ (org-cycle)
+ (re-search-forward "Sub-child")
+ (should (org-invisible-p))))
+
+(ert-deftest test-org/org-fold-reveal-broken-structure ()
+ "Test unfolding broken elements."
+ (let ((org-fold-core-style 'text-properties))
+ (org-test-with-temp-text
+ "<point>* Heading 1
+Text here"
+ (org-overview)
+ (re-search-forward "Text")
+ (should (org-invisible-p))
+ (goto-char 1)
+ (delete-char 1)
+ (re-search-forward "Text")
+ (should-not (org-invisible-p)))
+ (org-test-with-temp-text
+ "* Heading 1
+<point>:PROPERTIES:
+:ID: something
+:END:
+Text here"
+ (org-cycle)
+ (org-fold-hide-drawer-all)
+ (re-search-forward "ID")
+ (should (org-invisible-p))
+ (re-search-backward ":PROPERTIES:")
+ (delete-char 1)
+ (re-search-forward "ID")
+ (should-not (org-invisible-p)))
+ (org-test-with-temp-text
+ "* Heading 1
+<point>:PROPERTIES:
+:ID: something
+:END:
+Text here"
+ (org-cycle)
+ (org-fold-hide-drawer-all)
+ (re-search-forward "ID")
+ (should (org-invisible-p))
+ (re-search-forward ":END:")
+ (delete-char -1)
+ (re-search-backward "ID")
+ (should-not (org-invisible-p)))
+ (org-test-with-temp-text
+ "* Heading 1
+<point>#+begin_src emacs-lisp
+(+ 1 2)
+#+end_src
+Text here"
+ (org-cycle)
+ (org-fold-hide-drawer-all)
+ (re-search-forward "end")
+ (should (org-invisible-p))
+ (delete-char -1)
+ (re-search-backward "2")
+ (should-not (org-invisible-p)))))
+
+(ert-deftest test-org/re-hide-edits-inside-fold ()
+ "Test edits inside folded regions."
+ (org-test-with-temp-text
+ "<point>* Heading 1
+Text here"
+ (org-overview)
+ (org-set-property "TEST" "1")
+ (re-search-forward "TEST")
+ (should (org-invisible-p)))
+ (org-test-with-temp-text
+ "* Heading 1<point>
+Text here"
+ (org-overview)
+ (insert " and extra heading text")
+ (re-search-backward "heading")
+ (should-not (org-invisible-p)))
+ (org-test-with-temp-text
+ "* Heading 1
+Text<point> here"
+ (org-overview)
+ (insert " and extra text")
+ (re-search-backward "extra")
+ (should (org-invisible-p))))
+
;;; Yank and Kill
- [elpa] externals/org 0bca8bc418 30/44: org-fold-show-set-visibility: Fix edge case when folded region is at BOB, (continued)
- [elpa] externals/org 0bca8bc418 30/44: org-fold-show-set-visibility: Fix edge case when folded region is at BOB, ELPA Syncer, 2022/04/25
- [elpa] externals/org a8f4270ac1 21/44: org-manual: Update to new org-fold function names, ELPA Syncer, 2022/04/25
- [elpa] externals/org 0daa209a74 29/44: org-string-width: Work around `window-pixel-width' bug in old Emacs, ELPA Syncer, 2022/04/25
- [elpa] externals/org d2775da08d 35/44: test-ol/org-toggle-link-display: Fix compatibility with old Emacs, ELPA Syncer, 2022/04/25
- [elpa] externals/org 24c1c877cf 43/44: org-fold-core-fontify-region: Calculate jit-lock-bounds accurately, ELPA Syncer, 2022/04/25
- [elpa] externals/org 17e762426d 18/44: Move `org-buffer-list' to org-macs.el, ELPA Syncer, 2022/04/25
- [elpa] externals/org 3fba34900e 27/44: Fix org-fold--hide-drawers--overlays, ELPA Syncer, 2022/04/25
- [elpa] externals/org fc6314b267 39/44: org-fold.el: Fix typo, ELPA Syncer, 2022/04/25
- [elpa] externals/org f28f02bde9 34/44: org-link-make-string: Throw error when both LINK and DESCRIPTION are empty, ELPA Syncer, 2022/04/25
- [elpa] externals/org 062e30be8a 36/44: org-macs.el: Fix fontification checks take 2, ELPA Syncer, 2022/04/25
- [elpa] externals/org 6d4e65a124 20/44: Add org-fold-related tests,
ELPA Syncer <=
- [elpa] externals/org d4f65e74a2 17/44: org-compat: Work around some third-party packages using outline-* functions, ELPA Syncer, 2022/04/25
- [elpa] externals/org 9bc6c363da 40/44: org-fold-core: Fix edge case when fontification goes beyond requested, ELPA Syncer, 2022/04/25