[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive 670ae8050f 03/82: WIP: Add link tests
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive 670ae8050f 03/82: WIP: Add link tests |
Date: |
Mon, 25 Sep 2023 19:00:49 -0400 (EDT) |
branch: elpa/hyperdrive
commit 670ae8050fe5507394d5fe9fc562f3524345a99c
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
WIP: Add link tests
---
tests/test-hyperdrive.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/tests/test-hyperdrive.el b/tests/test-hyperdrive.el
index 6345d4309f..53e602f254 100644
--- a/tests/test-hyperdrive.el
+++ b/tests/test-hyperdrive.el
@@ -114,3 +114,64 @@
(hyperdrive-url-entry (make-url (hexify "/subdir/with-file"))))
((cl-struct hyperdrive public-key) hyperdrive))
(should (equal public-key test-hyperdrive-public-key))))
+
+;;;; Link testing
+
+(require 'hyperdrive-org)
+
+;;;;; URL links (i.e. "hyper://"-prefixed)
+
+(defun hyperdrive-test-org-url-link (url)
+ "Return the URL that would be opened by `hyperdrive-open' for URL."
+ (let (called-with-url)
+ (with-temp-buffer
+ (org-mode)
+ (insert url)
+ (goto-char 1)
+ (cl-letf (((symbol-function 'hyperdrive-open)
+ (lambda (entry &rest _)
+ (setf called-with-url (hyperdrive-entry-url entry)))))
+ (org-open-at-point)))
+ called-with-url))
+
+(ert-deftest hyperdrive-org-link-with-protocol-no-target ()
+ (let ((links '(("hyper://public_key/links%20test.org" .
"hyper://public_key/links%20test.org")
+ ("[[hyper://public_key/links%20test.org]]" .
"hyper://public_key/links%20test.org"))))
+ (dolist (link links)
+ (should (equal (hyperdrive-test-org-url-link (car link)) (cdr link))))))
+
+(ert-deftest hyperdrive-org-link-with-protocol-with-target ()
+ (let ((links '(("[[hyper://public_key/links%20test.org#Heading%20A]]"
+ . "hyper://public_key/links%20test.org#Heading%20A")
+ ("hyper://public_key/links%20test.org#Heading%20A"
+ . "hyper://public_key/links%20test.org#Heading%20A"))))
+ (dolist (link links)
+ (should (equal (hyperdrive-test-org-url-link (car link)) (cdr link))))))
+
+;;;;; Org links (i.e. not "hyper://"-prefixed)
+
+(defun hyperdrive-test-org-link (link)
+ ;; FIXME: Docstring.
+ "Return the URL that would be opened by `hyperdrive-open' for LINK.
+LINK is an Org link as a string."
+ (let (called-with-url)
+ (with-temp-buffer
+ (org-mode)
+ (hyperdrive-mode)
+ (insert link)
+ (goto-char 1)
+ (cl-letf (((symbol-function 'hyperdrive-open)
+ (lambda (entry &rest _)
+ (setf called-with-url (hyperdrive-entry-url entry)))))
+ (org-open-at-point)))
+ called-with-url))
+
+;; (ert-deftest
hyperdrive-org-link-without-protocol-without-target-filename-with-spaces ()
+;; (let ((links '(("[[links test.org]]"))))
+;; (dolist (link links)
+;; (should (equal )))))
+
+(ert-deftest
hyperdrive-org-link-without-protocol-without-file-with-asterisk-target ()
+ (let ((links '(("[[*Heading A]]"))))
+ (dolist (link links)
+ (should (equal (hyperdrive-test-org-link (car link)) "WHAT")))))
- [nongnu] elpa/hyperdrive 27d352dda2 70/82: Comment: Remove TODO, (continued)
- [nongnu] elpa/hyperdrive 27d352dda2 70/82: Comment: Remove TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 5588fb4e1d 71/82: Change/Fix: (hyperdrive--org-link-goto) Don't URI-decode target, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive dafc7f1b93 72/82: Fix: (hyperdrive--org-link-goto) Use org-link-search, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive c1932fb6fd 74/82: Change: (hyperdrive--org-open-at-point) Include target, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 20dd9efc70 76/82: Tidy, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 0a875bef41 78/82: Fix: Docstring, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive fe3c0c374a 79/82: Tests: Add relative/absolute link parsing tests, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 7d06ffd037 80/82: Meta: Update .gitignore, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 7826c10faa 81/82: Merge branch 'wip/org-heading-links', ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 903847d50e 82/82: Tidy: Docstrings, comments, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 670ae8050f 03/82: WIP: Add link tests,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 9b3b215444 04/82: WIP, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 62c487448f 06/82: WIP, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 28d4b1a6d6 08/82: Add: (hyperdrive-equal-p, -entry-hyperdrive-equal-p), ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive bdf9a94b49 09/82: WIP, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 96d458868b 10/82: WIP, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 8a453f0eb4 14/82: WIP: All tests passing! (so far), ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 82305e861b 15/82: WIP: Have macro define narrower tests, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive a72cf3820d 17/82: WIP: All tests pass, etc., ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive a040fa2686 18/82: WIP, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 5726648878 21/82: Change: (hyperdrive--format-entry-url) Docstring, ELPA Syncer, 2023/09/25