test-org-info.el 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ;;; test-org-info.el --- Tests for "org-info.el" -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017 Nicolas Goaziou
  3. ;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ;;; Code:
  15. (ert-deftest test-org-info/export ()
  16. "Test `org-info-export' specifications."
  17. ;; Export to HTML. Without node, refer to "Top".
  18. (should
  19. (equal (org-info-export "filename#node" nil 'html)
  20. "<a href=\"filename.html#node\">filename#node</a>"))
  21. (should
  22. (equal (org-info-export "filename" nil 'html)
  23. "<a href=\"filename.html#Top\">filename</a>"))
  24. ;; When exporting to HTML, ensure node names are expanded according
  25. ;; to (info "(texinfo) HTML Xref Node Name Expansion").
  26. (should
  27. (equal "_005f"
  28. (let ((name (org-info-export "#_" nil 'html)))
  29. (and (string-match "#\\(.*\\)\"" name)
  30. (match-string 1 name)))))
  31. (should
  32. (equal "_002d"
  33. (let ((name (org-info-export "#-" nil 'html)))
  34. (and (string-match "#\\(.*\\)\"" name)
  35. (match-string 1 name)))))
  36. (should
  37. (equal "A-node"
  38. (let ((name (org-info-export "#A node" nil 'html)))
  39. (and (string-match "#\\(.*\\)\"" name)
  40. (match-string 1 name)))))
  41. (should
  42. (equal "A-node-_002d_002d_002d-with-_005f_0027_0025"
  43. (let ((name (org-info-export "#A node --- with _'%" nil 'html)))
  44. (and (string-match "#\\(.*\\)\"" name)
  45. (match-string 1 name)))))
  46. ;; Export to Texinfo. Without a node name, refer to "Top".
  47. (should
  48. (equal (org-info-export "filename" nil 'texinfo)
  49. "@ref{Top,,,filename,}"))
  50. (should
  51. (equal (org-info-export "filename#node" nil 'texinfo)
  52. "@ref{node,,,filename,}")))
  53. (provide 'test-org-info)
  54. ;;; test-org-info.el ends here