branch: externals/hyperbole
commit 32f0d10126dd2600097f8ef8a425c80db47ddf25
Merge: db55e1a77b 66c9368c93
Author: Robert Weiner <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #344 from rswgnu/verify-expected-url-was-called
Verify url is called
---
ChangeLog | 6 ++++++
test/demo-tests.el | 45 +++++++++++++++++++++++++++++++++++----------
2 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 978c7890d1..f46e802793 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,12 @@
* Makefile (LOAD_EL): Avoid the trailing quotation mark.
+2023-06-22 Mats Lidell <[email protected]>
+
+* test/demo-tests.el (hypb-should-browse-demo-was-called) Add check that
+ url was called.
+ (demo-www-test-with-quotes): Test for url in quotes.
+
2023-06-22 Bob Weiner <[email protected]>
* man/hyperbole.texi (By Menu): Add section similar to that of Ibuts,
documenting
diff --git a/test/demo-tests.el b/test/demo-tests.el
index a8f48b2246..1431c44c1d 100644
--- a/test/demo-tests.el
+++ b/test/demo-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 30-Jan-21 at 12:00:00
-;; Last-Mod: 19-Feb-23 at 23:16:00 by Mats Lidell
+;; Last-Mod: 22-Jun-23 at 20:35:55 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -307,9 +307,12 @@
(should (string= "*mail*" (buffer-name))))
(hy-test-helpers:kill-buffer "*mail*")))
+(defvar hypb-should-browse-demo-was-called nil
+ "If non nil if the should-browse function was called.")
(defun demo-should-browse-twitter-url (url &optional new-window)
"Verify call with proper URL and optional NEW-WINDOW."
+ (setq hypb-should-browse-demo-was-called t)
(should (equal url "https://twitter.com/search?q=@fsf"))
(should (equal new-window nil)))
@@ -318,12 +321,14 @@
(with-temp-buffer
(insert "tw@fsf")
(goto-char 2)
- (let ((browse-url-browser-function 'demo-should-browse-twitter-url))
- (action-key))))
-
+ (let ((browse-url-browser-function 'demo-should-browse-twitter-url)
+ (hypb-should-browse-demo-was-called nil))
+ (action-key)
+ (should hypb-should-browse-demo-was-called))))
(defun demo-should-browse-github-url (url &optional new-window)
"Verify call with proper URL and optional NEW-WINDOW."
+ (setq hypb-should-browse-demo-was-called t)
(should (equal url "https://github.com/rswgnu/hyperbole"))
(should (equal new-window nil)))
@@ -333,8 +338,24 @@
(insert "https://github.com/rswgnu/hyperbole")
(goto-char 4)
(let ((browse-url-browser-function 'demo-should-browse-github-url)
- (hibtypes-github-default-user "rswgnu"))
- (action-key))))
+ (hibtypes-github-default-user "rswgnu")
+ (hypb-should-browse-demo-was-called nil))
+ (action-key)
+ (should hypb-should-browse-demo-was-called))))
+
+(ert-deftest demo-www-test-with-quotes ()
+ (let ((file (make-temp-file "hypb_" nil)))
+ (unwind-protect
+ (progn
+ (find-file file)
+ (insert "\"https://github.com/rswgnu/hyperbole\"")
+ (goto-char 4)
+ (let ((browse-url-browser-function 'demo-should-browse-github-url)
+ (hibtypes-github-default-user "rswgnu")
+ (hypb-should-browse-demo-was-called nil))
+ (action-key)
+ (should hypb-should-browse-demo-was-called)))
+ (hy-delete-file-and-buffer file))))
;; Github
(ert-deftest demo-github-user-default-test ()
@@ -342,16 +363,20 @@
(insert "gh#/hyperbole")
(goto-char 4)
(let ((browse-url-browser-function 'demo-should-browse-github-url)
- (hibtypes-github-default-user "rswgnu"))
- (action-key))))
+ (hibtypes-github-default-user "rswgnu")
+ (hypb-should-browse-demo-was-called nil))
+ (action-key)
+ (should hypb-should-browse-demo-was-called))))
(ert-deftest demo-github-ignore-default-test ()
(with-temp-buffer
(insert "gh#/rswgnu/hyperbole")
(goto-char 4)
(let ((browse-url-browser-function 'demo-should-browse-github-url)
- (hibtypes-github-default-user "whatever"))
- (action-key))))
+ (hibtypes-github-default-user "whatever")
+ (hypb-should-browse-demo-was-called nil))
+ (action-key)
+ (should hypb-should-browse-demo-was-called))))
;; Occur
(ert-deftest demo-occur-test ()