Merge branch 'maint'
[org-mode.git] / testing / lisp / test-org-open-at-point.el
blob78724c86938bf48c421f3e22610bfbc3bd2a1e13
1 ;;; test-org-open-at-point.el
3 ;; Copyright (c) Samuel Loury
4 ;; Authors: Samuel Loury
6 ;; Released under the GNU General Public License version 3
7 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
9 ;;;; Comments:
11 ;; Test for the org-open-at-point function
13 ;;; Code:
15 (save-excursion
16 (set-buffer (get-buffer-create "test-org-open-at-point.el"))
17 (setq ly-here
18 (file-name-directory
19 (or load-file-name (buffer-file-name)))))
21 (defun test-org-open-at-point/goto-fixture ()
22 (find-file-other-window
23 (concat ly-here "../examples/open-at-point.org"))
24 (set-buffer "open-at-point.org"))
26 (ert-deftest test-org-open-at-point/bracket-link-inside ()
27 "Test `org-open-at-point' from inside a bracket link."
28 (test-org-open-at-point/goto-fixture)
29 ;; go inside the bracket link
30 (goto-char 113)
31 (org-open-at-point)
32 ;; should now be in front of the header
33 (should (equal (point) 2)))
35 (ert-deftest test-org-open-at-point/plain-link-inside ()
36 "Test `org-open-at-point' from inside a plain link."
37 (test-org-open-at-point/goto-fixture)
38 ;; go inside the plain link
39 (goto-char 126)
40 (org-open-at-point)
41 ;; should now be in front of the header
42 (should (equal (point) 2)))
44 (ert-deftest test-org-open-at-point/bracket-link-before ()
45 "Test `org-open-at-point' from before a bracket link but in the same line."
46 (test-org-open-at-point/goto-fixture)
47 ;; go before the bracket link
48 (goto-char 83)
49 (message "point %s" (point))
50 (org-open-at-point)
51 ;; should now be in front of the header
52 (should (equal (point) 2)))
54 (ert-deftest test-org-open-at-point/plain-link-before ()
55 "Test `org-open-at-point' from before a plain link but in the same line."
56 (test-org-open-at-point/goto-fixture)
57 ;; go before the plain link
58 (goto-char 124)
59 (org-open-at-point)
60 ;; should now be in front of the header
61 (should (equal (point) 2)))