Browse Source

test-org-element: Add tests for links

* testing/lisp/test-org-element.el (test-org-element/link-parser): add
  tests.
Nicolas Goaziou 11 years ago
parent
commit
55e46fc260
1 changed files with 19 additions and 0 deletions
  1. 19 0
      testing/lisp/test-org-element.el

+ 19 - 0
testing/lisp/test-org-element.el

@@ -1428,6 +1428,25 @@ e^{i\\pi}+1=0
 	(lambda (l) (list (org-element-property :type l)
 		     (org-element-property :path l)
 		     (org-element-property :application l)))))))
+  ;; ... `:path' in a file-type link must be compatible with "file"
+  ;; scheme in URI syntax, even if Org syntax isn't.
+  (should
+   (org-test-with-temp-text-in-file ""
+     (let ((file (expand-file-name (buffer-file-name))))
+       (insert (format "[[file://%s]]" file))
+       (equal (org-element-property :path (org-element-context))
+	      (concat "//" file)))))
+  (should
+   (org-test-with-temp-text-in-file ""
+     (let ((file (expand-file-name (buffer-file-name))))
+       (insert (format "[[file:%s]]" file))
+       (equal (org-element-property :path (org-element-context))
+	      (concat "//" file)))))
+  (should
+   (org-test-with-temp-text-in-file ""
+     (let ((file (file-relative-name (buffer-file-name))))
+       (insert (format "[[file:%s]]" file))
+       (list (org-element-property :path (org-element-context)) file))))
   ;; Plain link.
   (should
    (org-test-with-temp-text "A link: http://orgmode.org"