-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.el
64 lines (47 loc) · 1.68 KB
/
test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(require 'ert)
(load-file "ox-md-title.el")
(defun with-org-md-title (func)
(org-md-title-add)
(funcall func)
(org-md-title-remove))
(ert-deftest title-test ()
(switch-to-buffer "*ox-md-title-test*")
(erase-buffer)
(insert "#+title: Title\n\n* Sub-headline")
(with-org-md-title #'org-md-export-as-markdown)
(let ((buffer (with-current-buffer
"*Org MD Export*"
(buffer-string))))
(should (string-match-p "^# Title" buffer))
(should (string-match-p "^## Sub-headline" buffer))))
(ert-deftest subtitle-test ()
(switch-to-buffer "*ox-md-title-test*")
(erase-buffer)
(insert "#+title: Title\n#+subtitle: Subtitle")
(with-org-md-title #'org-md-export-as-markdown)
(let ((buffer (with-current-buffer
"*Org MD Export*"
(buffer-string))))
(should (string-match-p "^# Title" buffer))
(should (string-match-p "^## Subtitle" buffer))))
(ert-deftest toc-test ()
(switch-to-buffer "*ox-md-title-test*")
(erase-buffer)
(insert "#+title: Title\n#+options: toc:2\n* Sub-headline")
(with-org-md-title #'org-md-export-as-markdown)
(let ((buffer (with-current-buffer
"*Org MD Export*"
(buffer-string))))
(should (string-match-p "^# Title" buffer))
(should (string-match-p "\[Sub-headline\]" buffer))
(should (string-match-p "^## Sub-headline" buffer))))
(ert-deftest title-without-title-test ()
(switch-to-buffer "*ox-md-title-test*")
(erase-buffer)
(insert "#+title: Title\n\n* Sub-headline")
(let ((org-export-with-title nil))
(with-org-md-title #'org-md-export-as-markdown))
(let ((buffer (with-current-buffer
"*Org MD Export*"
(buffer-string))))
(should-not (string-match-p "^# Title" buffer))))