test-org-html.el 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ;;; test-org-html.el
  2. ;; Copyright (c) ߛ David Maus
  3. ;; Authors: David Maus
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;;;; Comments:
  7. ;; Template test file for Org-mode tests
  8. ;;; Code:
  9. (let ((load-path (cons (expand-file-name
  10. ".." (file-name-directory
  11. (or load-file-name buffer-file-name)))
  12. load-path)))
  13. (require 'org-test)
  14. (require 'org-test-ob-consts))
  15. ;;; Tests
  16. (require 'org-html)
  17. (defvar test-org-html/export-link-alist
  18. '((:description "mailto: link"
  19. :link "[[mailto:john@example.tld]]"
  20. :expected "<a href=\"mailto:john@example.tld\">mailto:john@example.tld</a>"
  21. :opt-plist nil))
  22. "List of link definitions to test exporting for.
  23. Each cell is a property list that defines a link export test
  24. using the properties as follows:
  25. :description A string with a short description of the test. This
  26. is used as the doc-string of the created test.
  27. :link A string with the normalized Org mode link to test.
  28. :expected A string with the expected HTML markup.
  29. :opt-plist A property list with exporting options.")
  30. (defun test-org-html/export-link-factory ()
  31. "*Create tests for links defined in
  32. `test-org-html/export-link-alist'."
  33. (let ((count 0))
  34. (mapc
  35. (lambda (link)
  36. (eval
  37. `(ert-deftest ,(intern (format "test-org-html/export-link/%d" count)) ()
  38. ,(plist-get link :description)
  39. (should
  40. (string=
  41. ,(plist-get link :expected)
  42. (org-test-strip-text-props
  43. (org-html-handle-links ,(plist-get link :link) ,(plist-get link :opt-plist)))))))
  44. (setq count (1+ count))) test-org-html/export-link-alist)))
  45. ;; Create tests for link export
  46. (test-org-html/export-link-factory)
  47. (provide 'test-org-html)
  48. ;;; test-org-html.el ends here