branch: externals/hyperbole commit aead31cb63c25a256b0c776376ff544452f5c8ef Author: Mats Lidell <mats.lid...@lidells.se> Commit: GitHub <nore...@github.com>
Add tests for verifying action key on hyrolo matches (#486) --- ChangeLog | 9 ++++ test/hyrolo-tests.el | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2701742889..9492029400 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-03-14 Mats Lidell <ma...@gnu.org> + +* test/hyrolo-tests.el (hyrolo-tests--goto-org-match) + (hyrolo-tests--goto-kotl-body-match) + (hyrolo-tests--goto-kotl-header-match) + (hyrolo-tests--goto-kotl-body-with-slash-match) + (hyrolo-tests--goto-kotl-header-with-slash-match): Test action key on + a hyrolo match. + 2024-03-10 Bob Weiner <r...@gnu.org> * hversion.el: diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 460682dc81..1d8a96312a 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: 12-Mar-24 at 23:04:11 by Mats Lidell +;; Last-Mod: 15-Mar-24 at 23:34:41 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1513,6 +1513,127 @@ body (kill-buffer hyrolo-display-buffer) (hy-delete-files-and-buffers hyrolo-file-list)))) +(ert-deftest hyrolo-tests--goto-org-body-match () + "Move from body match to target at org file." + (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-next-match) + (action-key) + (should (string= (buffer-file-name) org-file1)) + (should (looking-at-p "body"))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + +(ert-deftest hyrolo-tests--goto-org-header-match () + "Move from heading match to target at org file." + (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 "h-org") + (hyrolo-next-match) + (action-key) + (should (string= (buffer-file-name) org-file1)) + (should (looking-at-p "h-org 1$"))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + +(ert-deftest hyrolo-tests--goto-kotl-body-match () + "Move from body match to target at kotl file." + (let* ((kotl-file1 (hyrolo-tests--gen-kotl-outline "h-kotl" "body" 1)) + (hyrolo-file-list (list kotl-file1))) + (unwind-protect + (progn + (hyrolo-grep "body") + (hyrolo-next-match) + (action-key) + (should (string= (buffer-file-name) kotl-file1)) + (should (looking-at-p "body$")) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + "\ + 1. h-kotl + body + + 1a. h-kotl 1 + body 1 + +" ))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + +(ert-deftest hyrolo-tests--goto-kotl-header-match () + "Move from heading match to target at first line in kotl file." + (let* ((kotl-file1 (hyrolo-tests--gen-kotl-outline "h-kotl" "body" 1)) + (hyrolo-file-list (list kotl-file1))) + (unwind-protect + (progn + (hyrolo-grep "h-kotl") + (hyrolo-next-match) + (action-key) + (should (string= (buffer-file-name) kotl-file1)) + (should (looking-at-p "h-kotl$")) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + "\ + 1. h-kotl + body + + 1a. h-kotl 1 + body 1 + +" ))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + +(ert-deftest hyrolo-tests--goto-kotl-body-with-slash-match () + "Move from body match to target line with slash in kotl file." + (let* ((kotl-file1 (hyrolo-tests--gen-kotl-outline "h-kotl" "body1 / body2" 1)) + (hyrolo-file-list (list kotl-file1))) + (unwind-protect + (progn + (hyrolo-grep "body2") + (hyrolo-next-match) + (action-key) + (should (string= (buffer-file-name) kotl-file1)) + (should (looking-at-p "body2$")) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + "\ + 1. h-kotl + body1 / body2 + + 1a. h-kotl 1 + body1 / body2 1 + +" ))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + +(ert-deftest hyrolo-tests--goto-kotl-header-with-slash-match () + "Move from heading match to target line with a slash in kotl file." + :expected-result :failed + (let* ((kotl-file1 (hyrolo-tests--gen-kotl-outline "h1 / h2" "body" 1)) + (hyrolo-file-list (list kotl-file1))) + (unwind-protect + (progn + (hyrolo-grep "h2") + (hyrolo-next-match) + (action-key) + (should (string= (buffer-file-name) kotl-file1)) + (should (looking-at-p "h2$")) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + "\ + 1. h1 / h2 + body + + 1a. h1 / h2 1 + body 1 + +" ))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + (provide 'hyrolo-tests) ;; This file can't be byte-compiled without the `el-mock' package