branch: externals/hyperbole
commit 4291c14138665c8cbb1c21f52edad5339e01aead
Author: Mats Lidell <mats.lid...@lidells.se>
Commit: GitHub <nore...@github.com>

    Add hyrolo reveal mode test (#459)
---
 ChangeLog            |  6 +++++
 test/hyrolo-tests.el | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6d7b775e4c..4e3704913f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-01  Mats Lidell  <ma...@gnu.org>
+
+* test/hyrolo-tests.el (hyrolo-tests--hyrolo-section-header): Helper that
+    returns a HyRolo section header.
+    (hyrolo-tests--hyrolo-reveal-mode): Add reveal mode test.
+
 2024-01-30  Mats Lidell  <ma...@gnu.org>
 
 * test/hyrolo-tests.el (hyrolo-tests--outline-as-string): Add helper that
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index fcf692f4fd..676dacbbfe 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:     30-Jan-24 at 14:24:16 by Mats Lidell
+;; Last-Mod:      1-Feb-24 at 00:10:57 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1255,5 +1255,73 @@ optional BEGIN and END only return that part of the 
buffer."
       (kill-buffer hyrolo-display-buffer)
       (hy-delete-files-and-buffers hyrolo-file-list))))
 
+(defun hyrolo-tests--hyrolo-section-header (filename)
+  "Return a hyrolo section header for FILENAME."
+  (concat
+   
"===============================================================================\n@loc>
 \""
+   filename
+   "\"\n"
+   
"===============================================================================\n"))
+
+(ert-deftest hyrolo-tests--hyrolo-reveal-mode ()
+  "Verify hidden sections are shown when using {TAB} to move through matches."
+  (skip-unless (not noninteractive))
+  (let* ((org-file1 (make-temp-file "hypb" nil ".org" 
hyrolo-tests--outline-content-org))
+         (hyrolo-file-list (list org-file1)))
+    (unwind-protect
+        (progn
+          (hyrolo-grep "body")
+          (hyrolo-top-level)
+
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1...\n* h-org 2...\n")
+                   (hyrolo-tests--outline-as-string)))
+
+          (should (hact 'kbd-key "TAB"))
+         (hy-test-helpers:consume-input-events)
+         (hy-test-helpers:consume-input-events)
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1\nbody\n** h-org 1.1...\n** h-org 
1.2...\n* h-org 2...\n")
+                   (hyrolo-tests--outline-as-string)))
+
+          (should (hact 'kbd-key "TAB"))
+          (hy-test-helpers:consume-input-events)
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1\nbody\n** h-org 1.1\nbody\n** h-org 
1.2...\n* h-org 2...\n")
+                   (hyrolo-tests--outline-as-string)))
+
+          (should (hact 'kbd-key "TAB"))
+          (hy-test-helpers:consume-input-events)
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1\nbody\n** h-org 1.1\nbody\n** h-org 
1.2\nbody\n*** h-org 1.2.1...\n* h-org 2...\n")
+                   (hyrolo-tests--outline-as-string)))
+
+          (should (hact 'kbd-key "TAB"))
+          (hy-test-helpers:consume-input-events)
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1\nbody\n** h-org 1.1\nbody\n** h-org 
1.2\nbody\n*** h-org 1.2.1\nbody\n* h-org 2...\n")
+                   (hyrolo-tests--outline-as-string)))
+
+          (should (hact 'kbd-key "TAB"))
+          (hy-test-helpers:consume-input-events)
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1\nbody\n** h-org 1.1\nbody\n** h-org 
1.2\nbody\n*** h-org 1.2.1\nbody\n* h-org 2\nbody\n** h-org-2.1...\n")
+                   (hyrolo-tests--outline-as-string)))
+
+          (should (hact 'kbd-key "TAB"))
+          (hy-test-helpers:consume-input-events)
+          (should (string=
+                   (concat (hyrolo-tests--hyrolo-section-header org-file1)
+                           "* h-org 1\nbody\n** h-org 1.1\nbody\n** h-org 
1.2\nbody\n*** h-org 1.2.1\nbody\n* h-org 2\nbody\n** h-org-2.1\nbody\n")
+                   (hyrolo-tests--outline-as-string))))
+      (kill-buffer hyrolo-display-buffer)
+      (hy-delete-files-and-buffers hyrolo-file-list))))
+
 (provide 'hyrolo-tests)
 ;;; hyrolo-tests.el ends here

Reply via email to