branch: externals/hyperbole
commit 2187b3522b5785860dd780d894583c844f42c256
Author: Mats Lidell <mats.lid...@lidells.se>
Commit: Mats Lidell <mats.lid...@lidells.se>

    Add test for hiding and showing
---
 ChangeLog            |  3 ++-
 test/hyrolo-tests.el | 39 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d3fd9e3122..192412611a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,8 @@
     (hyrolo-tests--gen-outline): Add helper for constructing org files for
     tests.
     (hyrolo-tests--outline-next-visible-header)
-    (hyrolo-tests--tab-through-matches): Add test for working with hyrolo
+    (hyrolo-tests--tab-through-matches)
+    (hyrolo-tests--outline-hide-show-heading): Add test for working with hyrolo
     matches.
 
 2023-12-31  Mats Lidell  <ma...@gnu.org>
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index db17adbd95..75690a57ce 100644
--- a/test/hyrolo-tests.el
+++ b/test/hyrolo-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <ma...@gnu.org>
 ;;
 ;; Orig-Date:    19-Jun-21 at 22:42:00
-;; Last-Mod:      1-Jan-24 at 16:24:40 by Mats Lidell
+;; Last-Mod:      1-Jan-24 at 19:18:41 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -465,7 +465,8 @@ Match a string in the second cell."
   (let ((tmp-file (make-temp-file "hypb" nil)))
     (unwind-protect
         (should-error
-         (setq hyrolo-file-list (list tmp-file)))
+         (let ((hyrolo-file-list (list tmp-file)))
+           ()))
       (hy-delete-file-and-buffer tmp-file))))
 
 ;; Outline movement tests
@@ -565,9 +566,41 @@ Example:
       (kill-buffer "*HyRolo*")
       (hy-delete-file-and-buffer org-file))))
 
+(ert-deftest hyrolo-tests--outline-hide-show-heading ()
+  "Verify hiding and showing headers."
+  (let* ((org-file (make-temp-file "hypb" nil ".org"
+                                   (hyrolo-tests--gen-outline "header" 2 
"body" 2)))
+         (hyrolo-file-list (list org-file)))
+    (unwind-protect
+        (progn
+          (hyrolo-grep "body")
+          (should (string= "*HyRolo*" (buffer-name)))
+
+          ;; Hide first line hides whole section
+          (should (looking-at-p "==="))
+          (should (hact 'kbd-key "h"))
+          (should (looking-at-p "^===+\.\.\.$"))
+          (save-excursion
+            (next-line)
+            (should (eobp)))
+          (should (hact 'kbd-key "a"))
+          (should (looking-at-p "^===+$"))
+
+          (should (hact 'kbd-key "n"))
+          (should (looking-at-p "^* header 1$"))
+          ;; BUG: This gives an unexpected error when trying to hide
+          ;; org-fold-region: Calling ‘org-fold-core-region’ with missing SPEC
+          (should-error (hact 'kbd-key "h"))
+          ;; Expected is not to fail on hiding the header.
+          ;; Seems to be version dependent for 29 and 30!?
+
+          ;; TBC - When bug above is resolved or understood better.
+          )
+      (kill-buffer "*HyRolo*")
+      (hy-delete-file-and-buffer org-file))))
 
 (ert-deftest hyrolo-tests--tab-through-matches ()
-  "Verify movement to next visible header."
+  "Verify tabbing through search matches."
   (let* ((org-file (make-temp-file "hypb" nil ".org"
                                    (hyrolo-tests--gen-outline "header" 2 
"body" 2)))
          (hyrolo-file-list (list org-file)))

Reply via email to