[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive dd795f5f2a 53/82: Test: Add tests for storing l
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive dd795f5f2a 53/82: Test: Add tests for storing links |
Date: |
Mon, 25 Sep 2023 19:00:54 -0400 (EDT) |
branch: elpa/hyperdrive
commit dd795f5f2ab4a1b5decdb31c4ff695d563382e5c
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>
Test: Add tests for storing links
---
tests/test-hyperdrive-org-link.el | 52 +++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/tests/test-hyperdrive-org-link.el
b/tests/test-hyperdrive-org-link.el
index 3c89b0c69c..812be73c2c 100644
--- a/tests/test-hyperdrive-org-link.el
+++ b/tests/test-hyperdrive-org-link.el
@@ -81,6 +81,58 @@
;;;; Tests
+;;;;; Storing links
+
+(cl-defun hyperdrive-test-org-store-link (contents &key public-key path)
+ "Return stored link to entry with PUBLIC-KEY, PATH, and CONTENTS.
+Point is indicated by ★."
+ (declare (indent defun))
+ (let ((org-id-link-to-org-use-id nil)
+ ;; (default-directory "/")
+ (entry (hyperdrive-entry-create
+ :hyperdrive (hyperdrive-create :public-key public-key)
+ :path path))
+ org-stored-links)
+ (with-temp-buffer
+ (insert contents)
+ (org-mode)
+ (hyperdrive-mode)
+ (setq-local hyperdrive-current-entry entry)
+ (goto-char (point-min))
+ (search-forward "★")
+ (org-store-link nil 'interactive))
+ org-stored-links))
+
+(ert-deftest hyperdrive-test-org-link-store/before-heading ()
+ (cl-destructuring-bind ((url desc))
+ (hyperdrive-test-org-store-link
+ "★
+* Heading A"
+ :public-key "deadbeef" :path "/foo/bar quux.org")
+ (should (string= "hyper://deadbeef/foo/bar%20quux.org" url))
+ (should (null desc))))
+
+(ert-deftest hyperdrive-test-org-link-store/on-heading-with-custom-id ()
+ (cl-destructuring-bind ((url desc))
+ (hyperdrive-test-org-store-link
+ "* Heading A
+:PROPERTIES:
+:CUSTOM_ID: baz zot
+:END:
+★"
+ :public-key "deadbeef" :path "/foo/bar quux.org")
+ (should (string= "hyper://deadbeef/foo/bar%20quux.org#%3A%3A%23baz%20zot"
url))
+ (should (string= "Heading A" desc))))
+
+(ert-deftest hyperdrive-test-org-link-store/on-heading-no-custom-id ()
+ (cl-destructuring-bind ((url desc))
+ (hyperdrive-test-org-store-link
+ "* Heading A
+★"
+ :public-key "deadbeef" :path "/foo/bar quux.org")
+ (should (string=
"hyper://deadbeef/foo/bar%20quux.org#%3A%3A%2AHeading%20A" url))
+ (should (string= "Heading A" desc))))
+
;; + Hyperdrive Org links :: Links to hyperdrive files/directories that are
valid within Org documents.
;; - With protocol prefix
- [nongnu] elpa/hyperdrive 04de0cb01a 44/82: Change: (hyperdrive--org-normalize-link) Check search-option first, (continued)
- [nongnu] elpa/hyperdrive 04de0cb01a 44/82: Change: (hyperdrive--org-normalize-link) Check search-option first, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 16cdce78bf 40/82: Comment: Add TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 6aa9346618 41/82: Comment: Add TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 18d7821a82 48/82: Test: Add different-drive-different-path-* tests, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 360c7d860f 49/82: Add: (hyperdrive--org-link-description) Utility function, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 3ea6fa6bc1 51/82: Comment: Correct explanation, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 1fb11bed18 50/82: Fix: (hyperdrive--org-insert-link-after-advice) Preserve description, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 505ee2626b 45/82: Change: (hyperdrive--format-entry-url) Hardcode fragment-prefix to #, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 923b1e6371 62/82: Comment: Remove "ing", ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 0b5adb547f 60/82: Test: Insert full "hyper://" links, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive dd795f5f2a 53/82: Test: Add tests for storing links,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 990d23ab55 57/82: Test: Rename org-mode/* to org-mode-*, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive dc8af9b72c 59/82: Test: Remove roundtrip tests, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive d704c5a181 64/82: Meta: Update changelog, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive f1bb94bb83 66/82: Change: (hyperdrive-org-link-follow) Don't jump to ID target, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 6293463834 67/82: Comment: Add TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 43f50f2ae7 69/82: Change/Fix: (hyperdrive--org-open-at-point) Don't handle fuzzy links, ELPA Syncer, 2023/09/25
- [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