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

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

[elpa] externals/hyperbole 4aff76f292: Add global button test cases (#15


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 4aff76f292: Add global button test cases (#155)
Date: Sun, 23 Jan 2022 09:57:32 -0500 (EST)

branch: externals/hyperbole
commit 4aff76f29235d5bf91edae01bf8ba3edbc076a57
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>

    Add global button test cases (#155)
---
 ChangeLog          | 13 +++++++++++-
 test/hbut-tests.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/hui-tests.el  | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 1fe1d9c84e..42d5bb9ff7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
-<<<<<<< HEAD
+2022-01-23  Mats Lidell  <matsl@gnu.org>
+
+* test/hui-tests.el (hui-gibut-create-link-to-file)
+    (hui-gibut-create-link-to-file-line)
+    (hui-gibut-create-link-to-file-line-and-column)
+    (hui-gibut-create-info-node): Test cases for global implicit buttons.
+
+* test/hbut-tests.el (gbut-program-eval-elisp)
+    (gbut-program-link-to-file, gbut-program-link-to-file-line)
+    (gbut-program-link-to-file-line-and-column): Test case for global
+    button programatically created button.
+
 2022-01-22  Bob Weiner  <rsw@gnu.org>
 
 * hycontrol.el (hycontrol-windows-grid-by-file-pattern): Add this command that 
creates
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
index 6170f4358b..367aa63659 100644
--- a/test/hbut-tests.el
+++ b/test/hbut-tests.el
@@ -101,6 +101,66 @@ Needed since hyperbole expands all links to absolute paths 
and
             (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
       (delete-file test-file))))
 
+(ert-deftest gbut-program-eval-elisp ()
+  "Programatically create gbut with eval-elisp."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect (expand-file-name hbmap:filename 
hbmap:dir-user)) => test-buffer)
+            (gbut:ebut-program "global" 'eval-elisp '()))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::eval-elisp))
+            (should (equal (hattr:get (hbut:at-p) 'args) '(())))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
+(ert-deftest gbut-program-link-to-file ()
+  "Programatically create gbut with eval-elisp."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect (expand-file-name hbmap:filename 
hbmap:dir-user)) => test-buffer)
+            (gbut:ebut-program "global" 'link-to-file test-file))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-file))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list test-file)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
+(ert-deftest gbut-program-link-to-file-line ()
+  "Programatically create gbut with eval-elisp."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect (expand-file-name hbmap:filename 
hbmap:dir-user)) => test-buffer)
+            (gbut:ebut-program "global" 'link-to-file-line test-file 10))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-file-line))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
+(ert-deftest gbut-program-link-to-file-line-and-column ()
+  "Programatically create gbut with eval-elisp."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect (expand-file-name hbmap:filename 
hbmap:dir-user)) => test-buffer)
+            (gbut:ebut-program "global" 'link-to-file-line-and-column 
test-file 10 20))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-file-line-and-column))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10 
20)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
 (ert-deftest hypb:program-create-ebut-in-buffer ()
   "Create button with hypb:program in buffer."
   (with-temp-buffer
diff --git a/test/hui-tests.el b/test/hui-tests.el
index d3fe147b56..a0f684c078 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -17,6 +17,7 @@
 
 (require 'ert)
 (require 'with-simulated-input)
+(require 'el-mock)
 (require 'hui)
 
 (load (expand-file-name "hy-test-helpers"
@@ -152,6 +153,67 @@ Modifying the button but keeping the label creates a 
dubbel label."
         (kill-buffer "*info*")
         (delete-file file)))))
 
+(ert-deftest hui-gibut-create-link-to-file ()
+  "Programatically create implicit button link to file."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect gbut:file) => test-buffer)
+            (hui:gibut-create "global" test-file))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-file))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list test-file)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
+(ert-deftest hui-gibut-create-link-to-file-line ()
+  "Programatically create implicit button link to file and line."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect gbut:file) => test-buffer)
+            (hui:gibut-create "global" (concat test-file ":10")))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-file-line))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
+(ert-deftest hui-gibut-create-link-to-file-line-and-column ()
+  "Programatically create implicit button link to file, line and column."
+  (let ((test-file (make-temp-file "gbut" nil ".txt")))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect gbut:file) => test-buffer)
+            (hui:gibut-create "global" (concat test-file ":10:20")))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-file-line-and-column))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10 
20)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
+(ert-deftest hui-gibut-create-info-node ()
+  "Programatically create implicit button link to info node."
+  (let ((test-file (make-temp-file "gbut" nil ".txt"))
+        (info-node "(hyperbole)Implicit Button"))
+    (setq test-buffer (find-file-noselect test-file))
+    (unwind-protect
+       (progn
+          (with-mock
+            (mock (find-file-noselect gbut:file) => test-buffer)
+            (hui:gibut-create "global" (concat "\"" info-node "\"")))
+         (with-current-buffer test-buffer
+            (should (eq (hattr:get (hbut:at-p) 'actype) 
'actypes::link-to-Info-node))
+            (should (equal (hattr:get (hbut:at-p) 'args) (list info-node)))
+            (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+      (delete-file test-file))))
+
 ;; This file can't be byte-compiled without `with-simulated-input' which
 ;; is not part of the actual dependencies, so:
 ;;   Local Variables:



reply via email to

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