test-ob-exp.el 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ;;; test-ob-exp.el
  2. ;; Copyright (c) 2010 Eric Schulte
  3. ;; Authors: Eric Schulte
  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. (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers ()
  17. "Testing export without any headlines in the org-mode file."
  18. (let ((html-file (concat (file-name-sans-extension org-test-no-heading-file)
  19. ".html")))
  20. (when (file-exists-p html-file) (delete-file html-file))
  21. (org-test-in-example-file org-test-no-heading-file
  22. ;; export the file to html
  23. (org-export-as-html nil))
  24. ;; should create a .html file
  25. (should (file-exists-p html-file))
  26. ;; should not create a file with "::" appended to it's name
  27. (should-not (file-exists-p (concat org-test-no-heading-file "::")))
  28. (when (file-exists-p html-file) (delete-file html-file))))
  29. (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-file ()
  30. "Testing export from buffers which are not visiting any file."
  31. (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*"))
  32. (should-not (get-buffer "*Org HTML Export*"))
  33. ;; export the file to HTML in a temporary buffer
  34. (org-test-in-example-file nil (org-export-as-html-to-buffer nil))
  35. ;; should create a .html buffer
  36. (should (buffer-live-p (get-buffer "*Org HTML Export*")))
  37. ;; should contain the content of the buffer
  38. (save-excursion
  39. (set-buffer (get-buffer "*Org HTML Export*"))
  40. (should (string-match (regexp-quote org-test-file-ob-anchor)
  41. (buffer-string))))
  42. (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*")))
  43. (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers2 ()
  44. "Testing export without any headlines in the org-mode file."
  45. (let ((html-file (concat (file-name-sans-extension
  46. org-test-link-in-heading-file)
  47. ".html")))
  48. (when (file-exists-p html-file) (delete-file html-file))
  49. (org-test-in-example-file org-test-link-in-heading-file
  50. ;; export the file to html
  51. (org-export-as-html nil))
  52. ;; should create a .html file
  53. (should (file-exists-p html-file))
  54. ;; should not create a file with "::" appended to it's name
  55. (should-not (file-exists-p (concat org-test-link-in-heading-file "::")))
  56. (when (file-exists-p html-file) (delete-file html-file))))
  57. ;; TODO
  58. ;; (ert-deftest ob-exp/noweb-on-export ()
  59. ;; "Noweb header arguments export correctly.
  60. ;; - yes expand on both export and tangle
  61. ;; - no expand on neither export or tangle
  62. ;; - tangle expand on only tangle not export"
  63. ;; (let (html)
  64. ;; (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
  65. ;; (org-narrow-to-subtree)
  66. ;; (let ((arg nil)
  67. ;; )
  68. ;; (mapcar (lambda (x)
  69. ;; (should (equal ""
  70. ;; (org-export-as-html nil
  71. ;; nil
  72. ;; nil
  73. ;; 'string))))
  74. ;; '("yes" "no" "tangle"))))))
  75. ;; TODO Test broken (args-out-of-range 1927 3462)
  76. ;; (ert-deftest ob-exp/exports-both ()
  77. ;; "Test the :exports both header argument.
  78. ;; The code block should create both <pre></pre> and <table></table>
  79. ;; elements in the final html."
  80. ;; (let (html)
  81. ;; (org-test-at-id "92518f2a-a46a-4205-a3ab-bcce1008a4bb"
  82. ;; (org-narrow-to-subtree)
  83. ;; (setq html (org-export-as-html nil nil nil 'string))
  84. ;; (should (string-match "<pre.*>[^\000]*</pre>" html))
  85. ;; (should (string-match "<table.*>[^\000]*</table>" html)))))
  86. ;; TODO Test Broken - causes ert to go off into the weeds
  87. ;; (ert-deftest ob-exp/export-subtree ()
  88. ;; (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
  89. ;; (org-mark-subtree)
  90. ;; (org-export-as-latex nil)))
  91. (provide 'test-ob-exp)
  92. ;;; test-ob-exp.el ends here