emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/webpaste db8c605 154/298: Rewrite test to cover both if li


From: ELPA Syncer
Subject: [nongnu] elpa/webpaste db8c605 154/298: Rewrite test to cover both if link is opened in external browser or not
Date: Thu, 9 Dec 2021 19:00:04 -0500 (EST)

branch: elpa/webpaste
commit db8c6050cb216a444b03e51f5cd786769850acb6
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>

    Rewrite test to cover both if link is opened in external browser or not
---
 test/webpaste-test.el | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/test/webpaste-test.el b/test/webpaste-test.el
index 7a0f0ec..bf49352 100644
--- a/test/webpaste-test.el
+++ b/test/webpaste-test.el
@@ -89,13 +89,28 @@
 (ert-deftest webpaste-test/return-url ()
   "Test returning of URL's to the user."
 
-  ;; Test to return a link and check that the message logged is the expected 
one
-  (should (equal
-           (webpaste-return-url "https://example.com/";)
-           "Added \"https://example.com/\"; to kill ring."))
+  ;; Override browse-url-generic to set a variable to t if triggered
+  (cl-letf (((symbol-function 'browse-url-generic)
+             (lambda (url) (setq webpaste-test/opened-in-browser t))))
 
-  ;; Check so the kill ring contain the correct contents
-  (should (equal (car kill-ring) "https://example.com/";)))
+    ;; Test to return a link and check that the message logged is the one we 
expect
+    (let ((webpaste/open-in-browser nil)(webpaste-test/opened-in-browser nil))
+      (should (equal
+               (webpaste-return-url "https://example.com/";)
+               "Added \"https://example.com/\"; to kill ring."))
+
+      ;; Check so the kill ring contain the correct contents
+      (should (equal (car kill-ring) "https://example.com/";))
+
+      ;; Check so the link wasn't opened in a browser
+      (should (equal webpaste-test/opened-in-browser nil)))
+
+    ;; Test that we call browse-url-generic with the link if option to open in
+    ;; browser is set
+    (let ((webpaste/open-in-browser t)(webpaste-test/opened-in-browser nil))
+      (webpaste-return-url "https://example.com/";)
+
+      (should (equal webpaste-test/opened-in-browser t)))))
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]