branch: externals/hyperbole
commit cd3c95a243d8c0535cdaed5f5c1da03c66d375ba
Author: Mats Lidell
Commit: GitHub
Add ebut:program tests (#105)
---
ChangeLog | 8
test/hbut-tests.el | 34 +++---
test/hypb-tests.el | 1 +
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 10714a4..d9afc2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,14 @@
2021-07-04 Mats Lidell
+* test/hbut-tests.el (ebut-program-link-to-directory)
+(ebut-program-link-to-directory-2, ebut-program-shell-cmd): Use
+actypes prefix after ebut:program change.
+
+* test/hbut-tests.el (hypb:program-create-ebut-in-buffer)
+(hypb:program-create-link-to-file-line-and-column-but-in-file): Add
+new test cases for ebut:program.
+
* test/hui-tests.el (hui-ebut-create-link-to-www-url)
(hui-ebut-modify-link-to-www-url-keeping-all-values-should-not-modify-buffer-or-ebut):
Add hui:ebut-create and hui:ebut-modify tests.
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
index 1b53c9b..e10e319 100644
--- a/test/hbut-tests.el
+++ b/test/hbut-tests.el
@@ -33,14 +33,14 @@
(delete-file file
(ert-deftest ebut-program-link-to-directory-2 ()
- "Programatically create ebut with link-to-directory."
+ "Programatically create ebut with link-to-directory using
`temporary-file-directory`."
(let ((file (make-temp-file "hypb_" nil ".txt")))
(unwind-protect
(progn
(find-file file)
- (ebut:program "label" 'link-to-directory (temporary-file-directory))
+ (ebut:program "label" 'link-to-directory temporary-file-directory)
(should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
- (should (equal (hattr:get (hbut:at-p) 'args)
'((temporary-file-directory
+ (should (equal (hattr:get (hbut:at-p) 'args) (list
temporary-file-directory)))
(should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
(delete-file file
@@ -78,8 +78,8 @@
(unwind-protect
(with-mock
(mock (find-file-noselect (expand-file-name hbmap:filename
hbmap:dir-user)) => test-buffer)
- (mock (ebut:program "label" 'actypes::link-to-directory "/tmp") => t)
- (gbut:ebut-program "label" 'actypes::link-to-directory "/tmp"))
+ (mock (ebut:program "label" 'link-to-directory "/tmp") => t)
+ (gbut:ebut-program "label" 'link-to-directory "/tmp"))
(delete-file test-file
(ert-deftest gbut-program-link-to-directory ()
@@ -90,11 +90,31 @@
(progn
(with-mock
(mock (find-file-noselect (expand-file-name hbmap:filename
hbmap:dir-user)) => test-buffer)
-(gbut:ebut-program "global" 'actypes::link-to-directory "/tmp"))
+(gbut:ebut-program "global" 'link-to-directory "/tmp"))
(with-current-buffer test-buffer
(should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
(should (equal (hattr:get (hbut:at-p) 'args) '("/tmp")))
-(should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"
+(should (equal (hattr:get (hbut:at-p) 'lbl-key) "global")))
+
+(ert-deftest hypb:program-create-ebut-in-buffer ()
+ "Create button with hypb:program in buffer.
+BUG: hbut:at-p does not recognise a button created within a buffer."
+ (with-temp-buffer
+(ebut:program "label" 'link-to-directory "/tmp")
+(should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::link-to-directory))
+(should (equal (hattr:get (hbut:at-p) 'args) '("./tmp")))
+(should (equal (hattr:get (hbut:at-p) 'lbl-key) "label"
+
+(ert-deftest hypb:program-create-link-to-file-line-and-column-but-in-file ()
+ "Create button that links to file with line and column with hypb:program in
buffer."
+ (let ((test-file (make-temp-file "test-file")))
+(unwind-protect
+(progn
+ (find-file test-file)
+ (ebut:program "label" 'link-to-file-line-and-column test-file 2 3)
+ (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 2 3)))
+ (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
(delete-file test-file
(provide 'hbut-tests)
diff --git a/test/hypb-tests.el b/test/hypb-tests.el
index 3109503..6e9d50e 100644
--- a/test/hypb-tests.el
+++ b/test/hypb-tests.el
@@ -16,6 +16,7 @@
;;; Code:
(require 'hypb)
+(require 'hbut)
(require 'ert)
;; Test for replace-regexp-in-string copied from emacs src