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

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

[elpa] externals/hyperbole 9ee1f8ea12: add tests for hypb 9 0 2 part1 (#


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 9ee1f8ea12: add tests for hypb 9 0 2 part1 (#562)
Date: Sun, 28 Jul 2024 15:58:09 -0400 (EDT)

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

    add tests for hypb 9 0 2 part1 (#562)
---
 ChangeLog              | 32 ++++++++++++++++++++++-
 hsys-org.el            |  6 ++---
 test/hibtypes-tests.el | 34 ++++++++++++++++++++++---
 test/hpath-tests.el    | 23 ++++++++++++++++-
 test/hsys-org-tests.el | 69 +++++++++++++++++++++++++++++++++++++++++++++++++-
 test/hui-tests.el      |  9 ++++++-
 test/hywiki-tests.el   | 19 +++++++++++++-
 7 files changed, 180 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 039d32d06e..15f5fec671 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,34 @@
-2024-07-09  Mats Lidell  <matsl@gnu.org>
+2024-07-28  Mats Lidell  <matsl@gnu.org>
+
+* test/hibtypes-tests.el (ibtypes:org-id-test): Test org-id ibut.
+
+2024-07-27  Mats Lidell  <matsl@gnu.org>
+
+* test/hsys-org-tests.el (hsys-org--get-agenda-tags): Test
+    hsys-org-get-agenda-tags.
+
+2024-07-26  Mats Lidell  <matsl@gnu.org>
+
+* hsys-org.el (hsys-org--agenda-tags-string): Update docstring.
+
+* test/hsys-org-tests.el (hsys-org--mode-p): Test hsys-org-mode-p.
+    (hsys-org---agenda-tags-string): Test hsys-org--agenda-tags-string.
+
+* test/hywiki-tests.el (hywiki-tests--at-tags-p): Test hywiki-at-tags-p.
+
+* test/hsys-org-tests.el (hsys-org--directory-at-tags-p): Test
+    hsys-org-directory-at-tags-p.
+
+2024-07-15  Mats Lidell  <matsl@gnu.org>
+
+* test/hsys-org-tests.el (hsys-org--at-tags-p): Test hsys-org-at-tags-p.
+
+* test/hpath-tests.el (hpath--to-markup-anchor): Test hpath:to-markup-anchor.
+
+* test/hui-tests.el (hui--link-possible-types): Add test for single-line
+    region.
+
+2024-07-14  Mats Lidell  <matsl@gnu.org>
 
 * Makefile (DOCKER_VERSIONS): Use 29.4 for local docker builds.
 
diff --git a/hsys-org.el b/hsys-org.el
index ce7f051533..66fa1747cb 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     2-Jul-16 at 14:54:14
-;; Last-Mod:     12-Jul-24 at 23:11:41 by Mats Lidell
+;; Last-Mod:     26-Jul-24 at 23:52:18 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -664,8 +664,8 @@ TARGET must be a string."
 
 (defun hsys-org--agenda-tags-string ()
   "When on or between Org tags, return an agenda match string for them.
-If on a colon, match to headlines with all tags around point, in any order.
-e.g. \":tag1: :tag2: :tag3: \".  Otherwise, just match to the single
+If on a colon, match to headlines with all tags around point, in any
+order.  e.g. \":tag1:tag2:tag3:\".  Otherwise, just match to the single
 tag around point."
   (let (range
        tags)
diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el
index eddd39d0a6..ce9a72665d 100644
--- a/test/hibtypes-tests.el
+++ b/test/hibtypes-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    20-Feb-21 at 23:45:00
-;; Last-Mod:     16-Jun-24 at 18:45:13 by Mats Lidell
+;; Last-Mod:     28-Jul-24 at 00:33:04 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -19,7 +19,7 @@
 ;;; Code:
 
 (require 'ert)
-(require 'hib-kbd)
+(require 'hibtypes)
 (require 'info)
 (require 'el-mock)
 (require 'hy-test-helpers "test/hy-test-helpers")
@@ -27,8 +27,6 @@
 (declare-function hy-test-helpers:consume-input-events "hy-test-helpers")
 (declare-function hy-test-helpers:should-last-message "hy-test-helpers")
 
-;; (ert-deftest org-link-outside-org-mode-test ()
-
 ;; Mail address
 (ert-deftest mail-address-at-p-test ()
   (with-temp-buffer
@@ -331,6 +329,34 @@
 
 ;; completion
 
+(ert-deftest ibtypes:org-id-test ()
+  "Verify `org-id' ibut."
+  (with-temp-buffer
+    (org-mode)
+    (insert (format ":ID: %s" (hypb:uuid)))
+    (goto-char 10)
+    (should (string=
+             "On ID definition; use {C-u M-RET} to copy a link to an ID."
+             (ibtypes::org-id))))
+
+  (let ((file (make-temp-file "hypb" nil ".org")))
+    (unwind-protect
+        (let ((id (hypb:uuid)))
+          (find-file file)
+          (org-mode)
+          (insert (format "* header
+:PROPERTIES:
+:ID: %s
+:END:
+
+<ID:%s>
+" id id))
+          (goto-char (point-min))
+          (should (and (search-forward "<ID:") (looking-at-p id)))
+          (mocklet (((actypes::link-to-org-id-marker *) => t))
+            (should (ibtypes::org-id))))
+      (hy-delete-file-and-buffer file))))
+
 ;; 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:
diff --git a/test/hpath-tests.el b/test/hpath-tests.el
index 413d755928..b8fb6753f3 100644
--- a/test/hpath-tests.el
+++ b/test/hpath-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    28-Feb-21 at 23:26:00
-;; Last-Mod:      1-Jun-24 at 20:45:10 by Mats Lidell
+;; Last-Mod:     15-Jul-24 at 00:07:11 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -442,6 +442,27 @@ dir/subdir:
               (should (string= (expand-file-name (concat filename ".ext") 
"dir/subdir")
                                (hpath:delimited-possible-path))))))))))
 
+(ert-deftest hpath--to-markup-anchor ()
+  "Verify `hpath:to-markup-anchor'."
+  (dolist (v '((text-mode 2) (outline-mode 0)))
+    (with-temp-buffer
+      (funcall (car v)) ;; Mode
+      (insert "Line 1\n* anchor\n* anchor")
+      (goto-char 4)
+      (hpath:to-markup-anchor nil "anchor")
+      (should (= (line-number-at-pos) 2))
+      (should (= (current-column) (cadr v)))
+
+      (goto-char 4)
+      (hpath:to-markup-anchor nil "anchor" 2)
+      (should (= (line-number-at-pos) 3))
+      (should (= (current-column) (cadr v)))
+
+      (goto-char 4)
+      (hpath:to-markup-anchor t nil)
+      (should (= (line-number-at-pos) 1))
+      (should (= (current-column) 0)))))
+
 (provide 'hpath-tests)
 
 :; This file can't be byte-compiled without the `el-mock' package
diff --git a/test/hsys-org-tests.el b/test/hsys-org-tests.el
index 2c7258d58b..62c647267c 100644
--- a/test/hsys-org-tests.el
+++ b/test/hsys-org-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    23-Apr-21 at 20:55:00
-;; Last-Mod:     29-Jun-24 at 15:13:29 by Bob Weiner
+;; Last-Mod:     28-Jul-24 at 11:44:20 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -20,6 +20,7 @@
 
 (require 'ert)
 (require 'hsys-org)
+(require 'org-agenda)
 (if t (require 'el-mock))
 
 (ert-deftest hsys-org:cycle-on-header-cycles-visibility ()
@@ -158,6 +159,72 @@ This is independent of the setting of 
`hsys-org-enable-smart-keys'."
                 (should (action-key))))))
       (hy-delete-file-and-buffer file))))
 
+(ert-deftest hsys-org--at-tags-p ()
+  "Verify `hsys-org-at-tags-p'."
+  (with-temp-buffer
+    (org-mode)
+    (save-excursion (insert "* header :tag:"))
+    (font-lock-ensure)
+    (should-not (hsys-org-at-tags-p))
+    (should (search-forward ":"))
+    (should (hsys-org-at-tags-p))))
+
+(ert-deftest hsys-org--directory-at-tags-p ()
+  "Verify `hsys-org-directory-at-tags-p'."
+  (mocklet ((hsys-org-at-tags-p => nil)
+            (string-prefix-p not-called))
+    (should-not (hsys-org-directory-at-tags-p)))
+  (let ((buffer-file-name (expand-file-name "buff" org-directory)))
+    (mocklet ((hsys-org-at-tags-p not-called))
+      (should (hsys-org-directory-at-tags-p t))))
+  (mocklet ((hsys-org-at-tags-p => t))
+    (let ((buffer-file-name (expand-file-name "buff" org-directory)))
+      (should (hsys-org-directory-at-tags-p))))
+  (mocklet ((hsys-org-at-tags-p => t)
+            (buffer-name => "*Org Agenda*"))
+    (let ((buffer-file-name nil))
+      (should (hsys-org-directory-at-tags-p))))
+  (mocklet ((hsys-org-at-tags-p => t)
+            (buffer-name => "*Another Agenda*"))
+    (let ((buffer-file-name nil))
+      (should-not (hsys-org-directory-at-tags-p)))))
+
+(ert-deftest hsys-org--mode-p ()
+  "Verify `hsys-org-mode-p' identifies an org major or minor-mode."
+  (with-temp-buffer
+    (org-mode)
+    (should (hsys-org-mode-p))
+    (org-agenda-mode)
+    (should (hsys-org-mode-p))))
+
+(ert-deftest hsys-org---agenda-tags-string ()
+  "Verify `hsys-org--agenda-tags-string'."
+  (with-temp-buffer
+    (org-mode)
+    (save-excursion (insert "* header :tag1:tag2:tag3:"))
+    (font-lock-ensure)
+
+    (should (and (search-forward "header ") (looking-at-p ":tag1:")))
+    (should (string= ":tag1:tag2:tag3" (hsys-org--agenda-tags-string)))
+
+    (forward-char)
+    (should (looking-at-p "tag1:"))
+    (should (string= ":tag1" (hsys-org--agenda-tags-string)))
+
+    (should (and (search-forward "tag1") (looking-at-p ":tag2:")))
+    (should (string= ":tag1:tag2:tag3" (hsys-org--agenda-tags-string)))
+
+    (forward-char)
+    (should (looking-at-p "tag2:"))
+    (should (string= ":tag2" (hsys-org--agenda-tags-string)))))
+
+(ert-deftest hsys-org--get-agenda-tags ()
+  "Verify `hsys-org-get-agenda-tags' calls org-consult-agenda-function."
+  (mocklet ((agenda-func => "agenda-func")
+            (hsys-org-at-tags-p => t)
+            (hsys-org--agenda-tags-string => ":tag"))
+    (should (string= "agenda-func" (hsys-org-get-agenda-tags #'agenda-func)))))
+
 (provide 'hsys-org-tests)
 
 ;; This file can't be byte-compiled without the `el-mock' package
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 6c5d11fa0d..27de42def6 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     31-May-24 at 15:58:58 by Mats Lidell
+;; Last-Mod:     13-Jul-24 at 23:42:26 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1113,6 +1113,13 @@ With point on label suggest that ibut for rename."
           (hy-test-helpers:ensure-link-possible-type 'link-to-kcell))
       (hy-delete-file-and-buffer file)))
 
+  ;; Single-line Region       link-to-string-match
+  (with-temp-buffer
+    (insert "a word")
+    (goto-char 4)
+    (mark-word)
+    (hy-test-helpers:ensure-link-possible-type 'link-to-string-match))
+
   ;; Outline Heading          link-to-string-match
   (let ((file (make-temp-file "hypb" nil ".otl" "* heading\nbody\n")))
     (unwind-protect
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 67263cfa94..c4fa52ff2e 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    18-May-24 at 23:59:48
-;; Last-Mod:      1-Jul-24 at 14:40:05 by Mats Lidell
+;; Last-Mod:     26-Jul-24 at 20:01:49 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -251,5 +251,22 @@
             (should-not (hproperty:but-get (point) 'face hywiki-word-face))))
       (hy-delete-dir-and-buffer hywiki-directory))))
 
+(ert-deftest hywiki-tests--at-tags-p ()
+  "Verify `hywiki-at-tags-p'."
+  (mocklet ((hsys-org-at-tags-p => nil))
+    (should-not (hywiki-at-tags-p)))
+  (mocklet ((hsys-org-at-tags-p not-called)
+            (hywiki-in-page-p => nil))
+    (should-not (hywiki-at-tags-p t)))
+  (mocklet ((hsys-org-at-tags-p => t)
+            (hywiki-in-page-p => t))
+    (should (hywiki-at-tags-p)))
+  (mocklet ((hsys-org-at-tags-p => t)
+            (hywiki-in-page-p => nil))
+    (mocklet ((buffer-name => "*HyWiki Tags*"))
+      (should (hywiki-at-tags-p)))
+    (mocklet ((buffer-name => "*Other Tags*"))
+      (should-not (hywiki-at-tags-p)))))
+
 (provide 'hywiki-tests)
 ;;; hywiki-tests.el ends here



reply via email to

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