aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Landell <dajva@users.noreply.github.com>2022-01-21 11:15:52 +0100
committerGitHub <noreply@github.com>2022-01-21 10:15:52 +0000
commita8019237a8f5e016a7c952fc2f673a2498a0e779 (patch)
treedbcaeded31f54e1adf7268c240807c3489710a16 /test
parent0bd966ba241a2458d5097e256543eceee50d462c (diff)
Support org-export-custom-protocol-maybe for links (#58)
An example of usage would be the orgit [1] package that supports translating local magit links to some http based repository viewer. 1. https://github.com/magit/orgit
Diffstat (limited to 'test')
-rw-r--r--test/ox-jira-test.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
index 3cbaffd..b042495 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -22,8 +22,11 @@
;;; Code:
(require 'ert)
+(require 'org-element)
(require 'ox)
(require 'ox-jira)
+(eval-when-compile
+ (require 'cl-lib))
(defun to-jira (string)
(org-export-string-as string 'jira nil '(:src-collapse-threshold 3)))
@@ -144,7 +147,20 @@ h1. {color:red}{{TODO}}{color} This is another headline {color:blue}{{:FOO:BAR:}
(should (equal "see [This Thing|#This Thing] for details\n"
(to-jira "see [[#Heading Name][This Thing]] for details")))
(should (equal "contact [User Name|~accountid:accountid] for details\n"
- (to-jira "contact [[~accountid:accountid][User Name]] for details\n"))))
+ (to-jira "contact [[~accountid:accountid][User Name]] for details\n")))
+ (cl-letf (((symbol-function #'org-export-custom-protocol-maybe)
+ (lambda (link &rest _)
+ (let ((path (org-element-property :path link)))
+ (if (string-prefix-p "example-protocol:" path)
+ "http://example.com"
+ nil)))))
+ (should (equal "fi [http://example.com] fo\n"
+ (to-jira "fi [[example-protocol:example.net]] fo")))
+ (should (equal "fi [Example|http://example.com] fo\n"
+ (to-jira "fi [[example-protocol:example.net][Example]] fo")))
+ (should (not (equal "fi [Example|[http://example.com] fo\n"
+ (to-jira "fi [[unsupported-protocol:example.net][Example]] fo"))))))
+
;; Check that text in paragraphs does not have hard newlines.
;;
(ert-deftest ox-jira-test/paragraphs ()