3 ;; Copyright (c) 2010-2012 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; Released under the GNU General Public License version 3
7 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
11 ;; Template test file for Org-mode tests
15 (let ((load-path (cons (expand-file-name
16 ".." (file-name-directory
17 (or load-file-name buffer-file-name
)))
20 (require 'org-test-ob-consts
))
24 (ert-deftest test-ob-exp
/org-babel-exp-src-blocks
/w-no-headers
()
25 "Testing export without any headlines in the org-mode file."
26 (let ((html-file (concat (file-name-sans-extension org-test-no-heading-file
)
28 (when (file-exists-p html-file
) (delete-file html-file
))
29 (org-test-in-example-file org-test-no-heading-file
30 ;; export the file to html
31 (org-export-as-html nil
))
32 ;; should create a .html file
33 (should (file-exists-p html-file
))
34 ;; should not create a file with "::" appended to it's name
35 (should-not (file-exists-p (concat org-test-no-heading-file
"::")))
36 (when (file-exists-p html-file
) (delete-file html-file
))))
38 (ert-deftest test-ob-exp
/org-babel-exp-src-blocks
/w-no-file
()
39 "Testing export from buffers which are not visiting any file."
40 (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*"))
41 (should-not (get-buffer "*Org HTML Export*"))
42 ;; export the file to HTML in a temporary buffer
43 (org-test-in-example-file nil
(org-export-as-html-to-buffer nil
))
44 ;; should create a .html buffer
45 (should (buffer-live-p (get-buffer "*Org HTML Export*")))
46 ;; should contain the content of the buffer
48 (set-buffer (get-buffer "*Org HTML Export*"))
49 (should (string-match (regexp-quote org-test-file-ob-anchor
)
51 (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*")))
53 (ert-deftest test-ob-exp
/org-babel-exp-src-blocks
/w-no-headers2
()
54 "Testing export without any headlines in the org-mode file."
55 (let ((html-file (concat (file-name-sans-extension
56 org-test-link-in-heading-file
)
58 (when (file-exists-p html-file
) (delete-file html-file
))
59 (org-test-in-example-file org-test-link-in-heading-file
60 ;; export the file to html
61 (org-export-as-html nil
))
62 ;; should create a .html file
63 (should (file-exists-p html-file
))
64 ;; should not create a file with "::" appended to it's name
65 (should-not (file-exists-p (concat org-test-link-in-heading-file
"::")))
66 (when (file-exists-p html-file
) (delete-file html-file
))))
68 (ert-deftest ob-exp
/noweb-on-export
()
69 "Noweb header arguments export correctly.
70 - yes expand on both export and tangle
71 - no expand on neither export or tangle
72 - tangle expand on only tangle not export"
73 (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
74 (org-narrow-to-subtree)
76 (org-export-as-html nil nil nil
'string
))
79 (org-test-with-temp-text-in-file
82 ;; check following ouput exists and in order
88 (setq test-point
(point)))
89 '("<head>" "</head>" "<body>"
90 "<code>:noweb</code> header argument expansion"
91 "<code>:noweb</code> header argument expansion"
97 "<<noweb-example1>>"
101 "<<noweb-example1>>"
102 "<<noweb-example2>>"
105 (ert-deftest ob-exp
/noweb-on-export-with-exports-results
()
106 "Noweb header arguments export correctly using :exports results.
107 - yes expand on both export and tangle
108 - no expand on neither export or tangle
109 - tangle expand on only tangle not export"
110 (org-test-at-id "8701beb4-13d9-468c-997a-8e63e8b66f8d"
111 (org-narrow-to-subtree)
113 (org-export-as-html nil nil nil
'string
))
116 (org-test-with-temp-text-in-file
119 ;; check following ouput exists and in order
121 (should (< test-point
125 (setq test-point
(point)))
126 '("<head>" "</head>" "<body>"
127 "<code>:noweb</code> header argument expansion using :exports results"
128 "<code>:noweb</code> header argument expansion using :exports results"
133 "<<noweb-example1>>"
135 "<<noweb-example1>>"
136 "<<noweb-example2>>"
139 (ert-deftest ob-exp
/exports-both
()
140 "Test the :exports both header argument.
141 The code block should create both <pre></pre> and <table></table>
142 elements in the final html."
143 (org-test-at-id "92518f2a-a46a-4205-a3ab-bcce1008a4bb"
144 (org-narrow-to-subtree)
146 (org-export-as-html nil nil nil
'string
))
149 (org-test-with-temp-text-in-file
152 ;; check following ouput exists and in order
154 (should (< test-point
158 (setq test-point
(point)))
159 '("<head>" "</head>" "<body>"
160 "Pascal's Triangle – exports both test"
161 "Pascal's Triangle – exports both test"
163 "defun" "pascals-triangle"
164 "if""list""list""let*""prev-triangle"
165 "pascals-triangle""prev-row""car""reverse""prev-triangle"
166 "append""prev-triangle""list""map""list"
167 "append""prev-row""append""prev-row""pascals-triangle"
171 "<tr>"">1<"">1<""</tr>"
172 "<tr>"">1<"">2<"">1<""</tr>"
173 "<tr>"">1<"">3<"">3<"">1<""</tr>"
174 "<tr>"">1<"">4<"">6<"">4<"">1<""</tr>"
175 "<tr>"">1<"">5<"">10<"">10<"">5<"">1<""</tr>"
179 (ert-deftest ob-exp
/mixed-blocks-with-exports-both
()
180 (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
181 (org-narrow-to-subtree)
183 (org-export-as-html nil nil nil
'string
))
185 (org-test-with-temp-text-in-file
188 ;; check following ouput exists and in order
190 (should (< test-point
194 (setq test-point
(point)))
195 '("<head>" "</head>" "<body>"
196 "mixed blocks with exports both"
197 "mixed blocks with exports both"
204 "\"code block results\""
206 "<pre class=\"example\">"
211 (provide 'test-ob-exp
)
213 ;;; test-ob-exp.el ends here