test-ob-exp.el 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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-headers ()
  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. (provide 'test-ob-exp)
  58. ;;; test-ob-exp.el ends here