forked from larrasket/ox-html-stable-ids.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.el
66 lines (59 loc) · 2.27 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
65
66
(require 'ert)
(load-file "ox-html-stable-ids.el")
(ert-deftest hello-world-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/hello-world.org")
(let ((org-html-stable-ids t))
(org-html-export-as-html))
(should (string-match-p
"<h2 id=\"hello-world"
(with-current-buffer "*Org HTML Export*" (buffer-string))))
(org-html-stable-ids-remove))
(ert-deftest disabled-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/hello-world.org")
(let ((org-html-stable-ids nil))
(org-html-export-as-html))
(should-not (string-match-p
"<h2 id=\"hello-world"
(with-current-buffer "*Org HTML Export*" (buffer-string))))
(org-html-stable-ids-remove))
(ert-deftest multiple-headlines-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/multiple-headlines.org")
(let ((org-html-stable-ids t))
(org-html-export-as-html))
(let ((buffer (with-current-buffer "*Org HTML Export*" (buffer-string))))
(should (string-match-p "<h2 id=\"hello-world" buffer))
(should (string-match-p "<h2 id=\"another-headline" buffer)))
(org-html-stable-ids-remove))
(ert-deftest src-block-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/src-block.org")
(let ((org-html-stable-ids t))
(org-html-export-as-html))
(let ((buffer (with-current-buffer "*Org HTML Export*" (buffer-string))))
(should (string-match-p "<pre class=\"src src-shell\">" buffer)))
(org-html-stable-ids-remove))
(ert-deftest example-block-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/example-block.org")
(let ((org-html-stable-ids t))
(org-html-export-as-html))
(let ((buffer (with-current-buffer "*Org HTML Export*" (buffer-string))))
(should (string-match-p "<pre class=\"example\">" buffer)))
(org-html-stable-ids-remove))
(ert-deftest duplicate-headlines-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/duplicate-headlines.org")
(should-error
(let ((org-html-stable-ids t))
(org-html-export-as-html)))
(org-html-stable-ids-remove))
(ert-deftest duplicate-headlines-with-custom-id-test ()
(org-html-stable-ids-add)
(find-file "test/fixtures/duplicate-headlines-with-custom-id.org")
(should-error
(let ((org-html-stable-ids t))
(org-html-export-as-html)))
(org-html-stable-ids-remove))