summaryrefslogtreecommitdiff
path: root/test-org-link-edit.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-03-03 01:30:14 -0500
committerKyle Meyer <kyle@kyleam.com>2017-03-03 01:30:14 -0500
commit0ccc32beb1bb23d15b531c865de8b997a32e3878 (patch)
tree98b72993da9a9732b021764d610cd29bc62a7d93 /test-org-link-edit.el
parent48ebfc757f713484b5427d0ca775fd1ae62f4775 (diff)
parent2cda5ae7d6141c06fc72e4c1b7f9f792cb8c2e05 (diff)
downloadorg-link-edit-0ccc32beb1bb23d15b531c865de8b997a32e3878.tar.gz
Merge branch 'km/transport'
Diffstat (limited to 'test-org-link-edit.el')
-rw-r--r--test-org-link-edit.el72
1 files changed, 69 insertions, 3 deletions
diff --git a/test-org-link-edit.el b/test-org-link-edit.el
index 6cf936a..7e4d2af 100644
--- a/test-org-link-edit.el
+++ b/test-org-link-edit.el
@@ -511,20 +511,86 @@ website"
(buffer-string)))))
+;;; Transport
+
+(ert-deftest test-org-link-edit/transport-next-link ()
+ "Test `org-link-edit-transport-next-link'."
+ (should
+ (string= "Here is \[\[http://orgmode.org/\]\[Org's\]\] website "
+ (org-test-with-temp-text
+ "Here is <point>Org's website http://orgmode.org/"
+ (org-link-edit-transport-next-link)
+ (buffer-string))))
+ (should
+ (string= " Here is \[\[http://orgmode.org/\]\[Org's\]\] website"
+ (org-test-with-temp-text
+ "http://orgmode.org/ Here is <point>Org's website"
+ (org-link-edit-transport-next-link 'previous)
+ (buffer-string))))
+ (should
+ (string= "\[\[http://orgmode.org/\]\[Here is Org's\]\] website "
+ (org-test-with-temp-text
+ "Here is Org's<point> website http://orgmode.org/"
+ (org-link-edit-transport-next-link
+ nil (point-min) (point))
+ (buffer-string))))
+ (should
+ (string= " Here is \[\[http://orgmode.org/\]\[Org's website\]\]"
+ (org-test-with-temp-text
+ "http://orgmode.org/ Here is <point>Org's website"
+ (org-link-edit-transport-next-link
+ 'previous (point) (point-max))
+ (buffer-string))))
+ (should-error
+ (org-test-with-temp-text
+ "Here is Org's website http://orgmode.org/<point>"
+ (org-link-edit-transport-next-link)
+ (buffer-string)))
+ (should-error
+ (org-test-with-temp-text
+ "Here is Org's website <point>http://orgmode.org/"
+ (org-link-edit-transport-next-link
+ nil (point-min) (point))
+ (buffer-string)))
+ )
+
+
;;; Other
+(ert-deftest test-org-link-edit/on-link-p ()
+ "Test `org-link-edit--on-link-p'."
+ ;; On plain link
+ (should
+ (org-test-with-temp-text "http://orgmode.org/"
+ (org-link-edit--on-link-p)))
+ ;; On bracket link
+ (should
+ (org-test-with-temp-text "\[\[http://orgmode.org/\]\[org\]\]"
+ (org-link-edit--on-link-p)))
+ ;; Point beyond link, but technically still within link element.
+ (should
+ (org-test-with-temp-text "\[\[http://orgmode.org/\]\[org\]\] <point>"
+ (org-link-edit--on-link-p)))
+ ;; Not on a link
+ (should-not
+ (org-test-with-temp-text " \[\[http://orgmode.org/\]\[org\]\]"
+ (org-link-edit--on-link-p)))
+ (should-not
+ (org-test-with-temp-text "not a link"
+ (org-link-edit--on-link-p))))
+
(ert-deftest test-org-link-edit/get-link-data ()
- "Test `org-link-edit--get-link-data'."
+ "Test `org-link-edit--link-data'."
;; Plain link
(cl-multiple-value-bind (beg end link desc)
(org-test-with-temp-text "http://orgmode.org/"
- (org-link-edit--get-link-data))
+ (org-link-edit--link-data))
(should (string= link "http://orgmode.org/"))
(should-not desc))
;; Bracket link
(cl-multiple-value-bind (beg end link desc)
(org-test-with-temp-text "\[\[http://orgmode.org/\]\[org\]\]"
- (org-link-edit--get-link-data))
+ (org-link-edit--link-data))
(should (string= link "http://orgmode.org/"))
(should (string= desc "org"))))