branch: externals/hyperbole
commit 1fcbd5deb2998f65140738e43816c27b58184c58
Author: Mats Lidell <[email protected]>
Commit: GitHub <[email protected]>
Add tests for hui:ibut-link-directly (#399)
---
ChangeLog | 7 +++++++
test/hui-tests.el | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index bc303aec67..19bb03ba5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-10-25 Mats Lidell <[email protected]>
+
+* test/hui-tests.el (hui--ibut-link-directly-to-file)
+ (hui--ibut-link-directly-to-dired)
+ (hui--ibut-link-directly-with-label): Test cases for
+ ibut-link-directly
+
2023-10-22 Mats Lidell <[email protected]>
* hui-select.el (hui-java-defun-prompt-regexp): Add prompt regexp as
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 56abb511e8..839ba5548d 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 30-Jan-21 at 12:00:00
-;; Last-Mod: 22-Oct-23 at 15:25:05 by Mats Lidell
+;; Last-Mod: 24-Oct-23 at 23:57:30 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -771,6 +771,59 @@ With point on label suggest that ibut for rename."
(goto-char (point-min))
(should (looking-at-p "<(new)><(new)>"))))
+(ert-deftest hui--ibut-link-directly-to-file ()
+ "Create a direct link to a file."
+ (let ((filea (make-temp-file "hypb" nil ".txt"))
+ (fileb (make-temp-file "hypb" nil ".txt" "1234567890")))
+ (unwind-protect
+ (progn
+ (delete-other-windows)
+ (find-file fileb)
+ (goto-char (point-max))
+ (split-window)
+ (find-file filea)
+ (hui:ibut-link-directly (get-buffer-window)
+ (get-buffer-window (get-file-buffer fileb)))
+ (should (string= (buffer-string) (concat "\"" fileb ":1:10\""))))
+ (hy-delete-file-and-buffer filea)
+ (hy-delete-file-and-buffer fileb))))
+
+(ert-deftest hui--ibut-link-directly-to-dired ()
+ "Create a direct link to a directory in dired."
+ :expected-result :failed
+ (let* ((file (make-temp-file "hypb" nil ".txt"))
+ (dir (file-name-parent-directory file))
+ dir-buf)
+ (unwind-protect
+ (progn
+ (delete-other-windows)
+ (setq dir-buf (dired dir))
+ (split-window)
+ (find-file file)
+ (hui:ibut-link-directly (get-buffer-window) (get-buffer-window
dir-buf))
+ ;; Was expecting here an ibut "/tmp" but <link-to-directory
+ ;; /tmp> could be possible too. Seems a link to the file the
+ ;; point in the dired buffer is on!? Is that expected?
+ (should (string= (buffer-string) (concat "\"" dir "\""))))
+ (hy-delete-file-and-buffer file))))
+
+(ert-deftest hui--ibut-link-directly-with-label ()
+ "Create a direct link with a label."
+ (let ((filea (make-temp-file "hypb" nil ".txt"))
+ (fileb (make-temp-file "hypb" nil ".txt" "1234567890")))
+ (unwind-protect
+ (progn
+ (delete-other-windows)
+ (find-file fileb)
+ (goto-char (point-max))
+ (split-window)
+ (find-file filea)
+ (with-simulated-input "label RET"
+ (hui:ibut-link-directly (get-buffer-window) (get-buffer-window
(get-file-buffer fileb)) 4))
+ (should (string= (buffer-string) (concat "<[label]> - " "\"" fileb
":1:10\""))))
+ (hy-delete-file-and-buffer filea)
+ (hy-delete-file-and-buffer fileb))))
+
;; This file can't be byte-compiled without `with-simulated-input' which
;; is not part of the actual dependencies, so:
;; Local Variables: