Skip to content

Commit 1fcbd5d

Browse files
authored
Add tests for hui:ibut-link-directly (#399)
1 parent ae5dd03 commit 1fcbd5d

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2023-10-25 Mats Lidell <[email protected]>
2+
3+
* test/hui-tests.el (hui--ibut-link-directly-to-file)
4+
(hui--ibut-link-directly-to-dired)
5+
(hui--ibut-link-directly-with-label): Test cases for
6+
ibut-link-directly
7+
18
2023-10-22 Mats Lidell <[email protected]>
29

310
* hui-select.el (hui-java-defun-prompt-regexp): Add prompt regexp as

test/hui-tests.el

+54-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Mats Lidell <[email protected]>
44
;;
55
;; Orig-Date: 30-Jan-21 at 12:00:00
6-
;; Last-Mod: 22-Oct-23 at 15:25:05 by Mats Lidell
6+
;; Last-Mod: 24-Oct-23 at 23:57:30 by Mats Lidell
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -771,6 +771,59 @@ With point on label suggest that ibut for rename."
771771
(goto-char (point-min))
772772
(should (looking-at-p "<(new)><(new)>"))))
773773

774+
(ert-deftest hui--ibut-link-directly-to-file ()
775+
"Create a direct link to a file."
776+
(let ((filea (make-temp-file "hypb" nil ".txt"))
777+
(fileb (make-temp-file "hypb" nil ".txt" "1234567890")))
778+
(unwind-protect
779+
(progn
780+
(delete-other-windows)
781+
(find-file fileb)
782+
(goto-char (point-max))
783+
(split-window)
784+
(find-file filea)
785+
(hui:ibut-link-directly (get-buffer-window)
786+
(get-buffer-window (get-file-buffer fileb)))
787+
(should (string= (buffer-string) (concat "\"" fileb ":1:10\""))))
788+
(hy-delete-file-and-buffer filea)
789+
(hy-delete-file-and-buffer fileb))))
790+
791+
(ert-deftest hui--ibut-link-directly-to-dired ()
792+
"Create a direct link to a directory in dired."
793+
:expected-result :failed
794+
(let* ((file (make-temp-file "hypb" nil ".txt"))
795+
(dir (file-name-parent-directory file))
796+
dir-buf)
797+
(unwind-protect
798+
(progn
799+
(delete-other-windows)
800+
(setq dir-buf (dired dir))
801+
(split-window)
802+
(find-file file)
803+
(hui:ibut-link-directly (get-buffer-window) (get-buffer-window dir-buf))
804+
;; Was expecting here an ibut "/tmp" but <link-to-directory
805+
;; /tmp> could be possible too. Seems a link to the file the
806+
;; point in the dired buffer is on!? Is that expected?
807+
(should (string= (buffer-string) (concat "\"" dir "\""))))
808+
(hy-delete-file-and-buffer file))))
809+
810+
(ert-deftest hui--ibut-link-directly-with-label ()
811+
"Create a direct link with a label."
812+
(let ((filea (make-temp-file "hypb" nil ".txt"))
813+
(fileb (make-temp-file "hypb" nil ".txt" "1234567890")))
814+
(unwind-protect
815+
(progn
816+
(delete-other-windows)
817+
(find-file fileb)
818+
(goto-char (point-max))
819+
(split-window)
820+
(find-file filea)
821+
(with-simulated-input "label RET"
822+
(hui:ibut-link-directly (get-buffer-window) (get-buffer-window (get-file-buffer fileb)) 4))
823+
(should (string= (buffer-string) (concat "<[label]> - " "\"" fileb ":1:10\""))))
824+
(hy-delete-file-and-buffer filea)
825+
(hy-delete-file-and-buffer fileb))))
826+
774827
;; This file can't be byte-compiled without `with-simulated-input' which
775828
;; is not part of the actual dependencies, so:
776829
;; Local Variables:

0 commit comments

Comments
 (0)