branch: externals/hyperbole
commit 97f4e12386f170a072ea82316cacea203abe0c7f
Author: bw <[email protected]>
Commit: bw <[email protected]>
hui--link-possible-types - ensure only 1 specific type per test
---
ChangeLog | 6 ++++++
test/hui-tests.el | 40 ++++++++++++++++++++--------------------
test/hy-test-helpers.el | 9 ++++++++-
3 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e4ced2a29c..3d792debff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-12-26 Bob Weiner <[email protected]>
+
+* test/hy-test-helpers.el (hy-test-helpers:ensure-link-possible-type): Add.
+ test/hui-tests.el (hui--link-possible-types): Use above function to ensure
+ 'hui:link-possible-types' returns one given type only for each test herein.
+
2023-12-26 Mats Lidell <[email protected]>
* test/hy-test-helpers.el (hy-delete-dir-and-buffer): Add test helper for
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 19ce491b5a..cc67aac880 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: 10-Dec-23 at 21:11:07 by Mats Lidell
+;; Last-Mod: 26-Dec-23 at 11:54:57 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -942,7 +942,7 @@ With point on label suggest that ibut for rename."
(find-file file)
(org-id-get-create nil)
(re-search-forward ":ID:")
- (should (equal (caar (hui:link-possible-types)) 'link-to-org-id)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-org-id))
(hy-delete-file-and-buffer file)))
;; Global Button link-to-gbut
@@ -952,46 +952,46 @@ With point on label suggest that ibut for rename."
(mocklet ((gbut:file => global-but-file))
(hui:gibut-create "global" "/tmp")
(find-file global-but-file)
- (should (equal (caar (hui:link-possible-types)) 'link-to-gbut)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-gbut))
(hy-delete-file-and-buffer global-but-file)))
;; Explicit Button link-to-ebut
(with-temp-buffer
(ebut:program "label" 'link-to-directory "/tmp")
- (should (equal (caar (hui:link-possible-types)) 'link-to-ebut)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-ebut))
;; Implicit Button link-to-ibut
(with-temp-buffer
(insert "<[ibut]> - \"/tmp\"")
(goto-char 5)
- (should (equal (caar (hui:link-possible-types)) 'link-to-ibut)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-ibut))
;; Bookmarks List link-to-bookmark
(with-temp-buffer
(insert " bookmark ~/bookmarked\n")
(bookmark-bmenu-mode)
- (should (equal (caar (hui:link-possible-types)) 'link-to-bookmark)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-bookmark))
;; Info Node link-to-Info-node
(with-temp-buffer
(insert "(info)node\n")
(goto-char 5)
(Info-mode)
- (should (equal (caar (hui:link-possible-types)) 'link-to-Info-node)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-Info-node))
;; Texinfo Node link-to-texinfo-node
(with-temp-buffer
(insert "@node node\n")
(goto-char 5)
(texinfo-mode)
- (should (equal (caar (hui:link-possible-types)) 'link-to-texinfo-node)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-texinfo-node))
;; Mail Reader Message link-to-mail
(let ((hmail:reader 'gnus-article-mode))
(with-temp-buffer
(gnus-article-mode)
(mocklet ((rmail:msg-id-get => "msg-id"))
- (should (equal (caar (hui:link-possible-types)) 'link-to-mail)))))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-mail))))
;; Directory Name link-to-directory
(let ((dir (make-temp-file "hypb" t)))
@@ -1004,15 +1004,15 @@ With point on label suggest that ibut for rename."
;; behavior?
(with-current-buffer (dired dir)
(goto-char 1)
- (should (equal (caar (hui:link-possible-types))
'link-to-directory)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-directory))
(with-temp-buffer
(insert dir)
(goto-char 4)
- (should (equal (caar (hui:link-possible-types)) 'link-to-ibut)))
;; Expected: link-to-directory
+ (hy-test-helpers:ensure-link-possible-type 'link-to-ibut)) ;;
Expected: link-to-directory
(with-temp-buffer
(insert "/ssh:[email protected]:/home/user/file\n")
(goto-char 4)
- (should (equal (caar (hui:link-possible-types)) 'link-to-ibut))))
;; Expected: link-to-directory
+ (hy-test-helpers:ensure-link-possible-type 'link-to-ibut))) ;;
Expected: link-to-directory
(hy-delete-dir-and-buffer dir)))
;; File Name link-to-file
@@ -1021,15 +1021,15 @@ With point on label suggest that ibut for rename."
(unwind-protect
(let ((hargs:reading-type 'file))
(with-current-buffer (dired temporary-file-directory)
- (should (equal (caar (hui:link-possible-types)) 'link-to-file)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-file))
(with-temp-buffer
(insert temporary-file-directory)
(goto-char 4)
- (should (equal (caar (hui:link-possible-types)) 'link-to-ibut)))
;; Expected: link-to-file
+ (hy-test-helpers:ensure-link-possible-type 'link-to-ibut)) ;;
Expected: link-to-file
(with-temp-buffer
(insert "/ssh:[email protected]:/home/user/\n")
(goto-char 4)
- (should (equal (caar (hui:link-possible-types)) 'link-to-ibut))))
;; Expected: link-to-file
+ (hy-test-helpers:ensure-link-possible-type 'link-to-ibut))) ;;
Expected: link-to-file
(hy-delete-file-and-buffer file)
(hy-delete-dir-and-buffer temporary-file-directory)))
@@ -1039,7 +1039,7 @@ With point on label suggest that ibut for rename."
(progn
(find-file file)
(insert "first")
- (should (equal (caar (hui:link-possible-types)) 'link-to-kcell)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-kcell))
(hy-delete-file-and-buffer file)))
;; Outline Heading link-to-string-match
@@ -1049,7 +1049,7 @@ With point on label suggest that ibut for rename."
(find-file file)
(outline-mode)
(goto-char 1)
- (should (equal (caar (hui:link-possible-types))
'link-to-string-match)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-string-match))
(hy-delete-file-and-buffer file)))
;; Buffer attached to File link-to-file
@@ -1057,7 +1057,7 @@ With point on label suggest that ibut for rename."
(unwind-protect
(progn
(find-file file)
- (should (equal (caar (hui:link-possible-types)) 'link-to-file)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-file))
(hy-delete-file-and-buffer file)))
;; EOL in Dired Buffer link-to-directory (dired dir)
@@ -1065,12 +1065,12 @@ With point on label suggest that ibut for rename."
(unwind-protect
(with-current-buffer (dired dir)
(goto-char 1) ;; EOL does not seem to matter!?
- (should (equal (caar (hui:link-possible-types)) 'link-to-directory)))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-directory))
(hy-delete-dir-and-buffer dir)))
;; Buffer without File link-to-buffer-tmp"
(with-temp-buffer
- (should (equal (caar (hui:link-possible-types)) 'link-to-buffer-tmp))))
+ (hy-test-helpers:ensure-link-possible-type 'link-to-buffer-tmp)))
;; This file can't be byte-compiled without `with-simulated-input' which
;; is not part of the actual dependencies, so:
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index f11dd33862..9d920e96cf 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 30-Jan-21 at 12:00:00
-;; Last-Mod: 22-Dec-23 at 16:03:21 by Mats Lidell
+;; Last-Mod: 26-Dec-23 at 11:55:42 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -27,6 +27,13 @@
(run-with-timer 0.1 nil (lambda () (exit-recursive-edit)))
(recursive-edit))
+(defun hy-test-helpers:ensure-link-possible-type (type)
+ "At point, ensure `hui:link-possible-types' returns a single TYPE."
+ (let* ((possible-types (hui:link-possible-types))
+ (first-type (caar possible-types)))
+ (should (= (length possible-types) 1))
+ (should (equal (caar (hui:link-possible-types)) type))))
+
(defun hy-test-helpers:should-last-message (msg)
"Verify last message is MSG."
(with-current-buffer (messages-buffer)