Browse Source

Add tests for `org-export-insert-image-links'

* testing/lisp/test-ox.el (test-org-export/insert-image-links): New
  test.
Nicolas Goaziou 8 years ago
parent
commit
aae5149d10
1 changed files with 27 additions and 0 deletions
  1. 27 0
      testing/lisp/test-ox.el

+ 27 - 0
testing/lisp/test-ox.el

@@ -2702,6 +2702,33 @@ Para2"
       (org-element-map (org-element-parse-buffer) 'link 'identity nil t))
     '(("custom-id" . "id")))))
 
+(ert-deftest test-org-export/insert-image-links ()
+  "Test `org-export-insert-image-links' specifications."
+  (should-not
+   (member "file"
+	   (org-test-with-parsed-data "[[http://orgmode.org][file:image.png]]"
+	     (org-element-map tree 'link
+	       (lambda (l) (org-element-property :type l))))))
+  (should
+   (member "file"
+	   (org-test-with-parsed-data "[[http://orgmode.org][file:image.png]]"
+	     (org-element-map (org-export-insert-image-links tree info) 'link
+	       (lambda (l) (org-element-property :type l))))))
+  ;; With optional argument RULES, recognize different links as
+  ;; images.
+  (should-not
+   (member "file"
+	   (org-test-with-parsed-data "[[http://orgmode.org][file:image.xxx]]"
+	     (org-element-map (org-export-insert-image-links tree info) 'link
+	       (lambda (l) (org-element-property :type l))))))
+  (should
+   (member "file"
+	   (org-test-with-parsed-data "[[http://orgmode.org][file:image.xxx]]"
+	     (org-element-map
+		 (org-export-insert-image-links tree info '(("file" . "xxx")))
+		 'link
+	       (lambda (l) (org-element-property :type l)))))))
+
 (ert-deftest test-org-export/fuzzy-link ()
   "Test fuzzy links specifications."
   ;; Link to an headline should return headline's number.