[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive 2c3bc705c7 56/82: Test: Add hyperdrive-test-org
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive 2c3bc705c7 56/82: Test: Add hyperdrive-test-org-store-link-deftest macro |
Date: |
Mon, 25 Sep 2023 19:00:54 -0400 (EDT) |
branch: elpa/hyperdrive
commit 2c3bc705c767c71098587341a406e40f778fc78b
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>
Test: Add hyperdrive-test-org-store-link-deftest macro
---
tests/test-hyperdrive-org-link.el | 71 +++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/tests/test-hyperdrive-org-link.el
b/tests/test-hyperdrive-org-link.el
index c068a1591f..c9c6883d05 100644
--- a/tests/test-hyperdrive-org-link.el
+++ b/tests/test-hyperdrive-org-link.el
@@ -90,7 +90,25 @@
:content "★
* Heading A"
:url "hyper://deadbeef/foo/bar%20quux.org"
- :desc nil))
+ :desc nil)
+ (org-mode/on-heading-with-custom-id
+ :public-key "deadbeef"
+ :path "/foo/bar quux.org"
+ :content
+ "* Heading A
+:PROPERTIES:
+:CUSTOM_ID: baz zot
+:END:
+★"
+ :url "hyper://deadbeef/foo/bar%20quux.org#%3A%3A%23baz%20zot"
+ :desc "Heading A")
+ (org-mode/on-heading-no-custom-id
+ :public-key "deadbeef"
+ :path "/foo/bar quux.org"
+ :content "* Heading A
+★"
+ :url "hyper://deadbeef/foo/bar%20quux.org#%3A%3A%2AHeading%20A"
+ :desc "Heading A"))
"Alist keyed by scenario symbols.
Each value is a plist with the following keys:
@@ -122,37 +140,26 @@ Point is indicated by ★."
(org-store-link nil 'interactive))
org-stored-links))
-(ert-deftest hyperdrive-test-org-link-store/before-heading ()
- (pcase-let* (((map :public-key :path :content
- (:url expected-url) (:desc expected-desc))
- (alist-get 'org-mode/before-heading
- hyperdrive-test-org-store-link-scenarios))
- (`((,got-url ,got-desc))
- (hyperdrive-test-org-store-link content
- :public-key public-key :path path)))
- (should (string= expected-url got-url))
- (should (string= expected-desc got-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))))
+(defmacro hyperdrive-test-org-store-link-deftest (scenario)
+ "Test scenario in `hyperdrive-test-org-store-link-scenarios'."
+ (let ((test-name (intern
+ (format "hyperdrive-test-org-store-link/%s" scenario))))
+ `(ert-deftest ,test-name ()
+ (pcase-let* (((map :public-key :path :content
+ (:url expected-url) (:desc expected-desc))
+ ;; TODO: Is there a better syntax that explicit `quote'?
+ (alist-get (quote ,scenario)
+ hyperdrive-test-org-store-link-scenarios))
+ (`((,got-url ,got-desc))
+ (hyperdrive-test-org-store-link content
+ :public-key public-key :path path)))
+ (should (string= expected-url got-url))
+ (should (string= expected-desc got-desc))))))
+
+;; TODO: Loop through `hyperdrive-test-org-store-link-scenarios'?
+(hyperdrive-test-org-store-link-deftest org-mode/before-heading)
+(hyperdrive-test-org-store-link-deftest org-mode/on-heading-with-custom-id)
+(hyperdrive-test-org-store-link-deftest org-mode/on-heading-no-custom-id)
;; + Hyperdrive Org links :: Links to hyperdrive files/directories that are
valid within Org documents.
- [nongnu] elpa/hyperdrive 80ec05b3b5 28/82: Add: (--org-normalize-link) Gut --org-insert-link-after-advice, (continued)
- [nongnu] elpa/hyperdrive 80ec05b3b5 28/82: Add: (--org-normalize-link) Gut --org-insert-link-after-advice, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 89fa2fe4a9 30/82: Tidy: (hyperdrive--org-normalize-link) Deduplicate full URL codepath, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive a4b2c538df 31/82: Tidy: (hyperdrive--org-normalize-link) Use if instead of cond, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 36a18f326e 34/82: Change: (--org-normalize-link) Return early with search option, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 91c3478593 36/82: Change: (hyperdrive--org-normalize-link) Use file-name-directory, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive c4567c4b9f 46/82: Change: (hyperdrive--org-normalize-link) Use hyperdrive-entry-url, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 28151f3db9 39/82: Change: (--org-normalize-link) Split adaptive into absolute/relative, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 25af84f5e4 52/82: Change: (hyperdrive--org-link) Add "::" to stored link, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 032a77ea2d 43/82: Test: -org-link/same-drive-different-path with heading, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive c99013b23a 61/82: Comment: Add outline heading, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 2c3bc705c7 56/82: Test: Add hyperdrive-test-org-store-link-deftest macro,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 46e6a1201f 54/82: Comment: Add TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 68e55a0ab6 55/82: Test: Add hyperdrive-test-org-store-link-scenarios, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 6c203e3e34 58/82: Test: Test inserting links, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 0d92314c4f 65/82: Docs: Document new advised org-insert-link behavior, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 834c4a8908 63/82: Change: Rename test-hyperdrive-org.el, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 658164484b 68/82: Tidy: (hyperdrive-test-org-entry-create) Don't bind org-stored-links, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 373d55c1d8 73/82: Comment: Add TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 8c4c989c01 75/82: WIP: Don't store "::" in target in entry etc slot, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 759142d99e 77/82: Tests: Remove old Org link tests from main test file, ELPA Syncer, 2023/09/25