branch: externals/hyperbole
commit 9ced23a3c86a3d5abb2d65c12ea74d4e420576fa
Author: Mats Lidell <mats.lid...@lidells.se>
Commit: GitHub <nore...@github.com>

    Unit tests for hattr:{is-p,actype-is-p,ibtype-is-p} (#724)
---
 ChangeLog          |  6 ++++++
 test/hbut-tests.el | 27 ++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9da3dc2520..bc11070f3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-05-01  Mats Lidell  <ma...@gnu.org>
+
+* test/hbut-tests.el (hbut-tests--hattr-is-p)
+    (hbut-tests--hattr-ibtype-is-p, hbut-tests--hattr-actype-is-p): Unit
+    tests.
+
 2025-04-28  Mats Lidell  <ma...@gnu.org>
 
 * man/.dir-locals.el: Add before-save-hook for automating date updates.
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
index 8e6ea6d799..44569fc210 100644
--- a/test/hbut-tests.el
+++ b/test/hbut-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <ma...@gnu.org>
 ;;
 ;; Orig-Date:    30-may-21 at 09:33:00
-;; Last-Mod:     22-Dec-24 at 21:58:44 by Mats Lidell
+;; Last-Mod:      1-May-25 at 23:33:16 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -795,6 +795,31 @@ See #10 for the proper way to add an ibutton name.
           (gbut:act "Link"))
       (hy-delete-file-and-buffer global-but-file))))
 
+(ert-deftest hbut-tests--hattr-is-p ()
+  "Verify `hattr:is-p'."
+  (should-not (hattr:is-p "non symbol" 'any))
+  (should-not (hattr:is-p nil 'any))
+  (mocklet (((hattr:get 'hbut:current 'symbol) => 'value))
+    (should (hattr:is-p 'symbol 'value))
+    (should-not (hattr:is-p 'symbol 'other-value)))
+  (mocklet (((hattr:get 'hbut-symbol 'symbol) => 'value))
+    (should (hattr:is-p 'symbol 'value 'hbut-symbol))
+    (should-not (hattr:is-p 'symbol 'other-value 'hbut-symbol))))
+
+(ert-deftest hbut-tests--hattr-ibtype-is-p ()
+  "Verify `hattr:ibtype-is-p'."
+  (mocklet (((hattr:is-p 'categ 'ibtype nil) => t))
+    (should (hattr:ibtype-is-p 'ibtype)))
+  (mocklet (((hattr:is-p 'categ 'ibtype 'ibut-symbol) => t))
+    (should (hattr:ibtype-is-p 'ibtype 'ibut-symbol))))
+
+(ert-deftest hbut-tests--hattr-actype-is-p ()
+  "Verify `hattr:actype-is-p'."
+  (mocklet (((hattr:is-p 'actype 'ibtype nil) => t))
+    (should (hattr:actype-is-p 'ibtype)))
+  (mocklet (((hattr:is-p 'actype 'ibtype 'ibut-symbol) => t))
+    (should (hattr:actype-is-p 'ibtype 'ibut-symbol))))
+
 ;; This file can't be byte-compiled without the `el-mock' package (because of
 ;; the use of the `with-mock' macro), which is not a dependency of Hyperbole.
 ;;  Local Variables:

Reply via email to