summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Loury <konubinixweb@gmail.com>2013-03-16 19:12:42 (GMT)
committer Bastien Guerry <bzg@altern.org>2013-03-16 19:27:00 (GMT)
commit0c82deb42152a853a48646097748b7e6e16a444d (patch)
tree6f204c2ba55319ead941efcb18e37d5d7be7bf32
parentacbf00ea24696270d93e5d697a68edb5924d242c (diff)
downloadorg-mode-0c82deb42152a853a48646097748b7e6e16a444d.zip
org-mode-0c82deb42152a853a48646097748b7e6e16a444d.tar.gz
Test the org-open-at-point function.
* testing/examples/open-at-point.org: new file. * testing/lisp/test-org-open-at-point.el: new file. This tests only the function when inside or before bracket links and plain links.
-rw-r--r--testing/examples/open-at-point.org8
-rw-r--r--testing/lisp/test-org-open-at-point.el61
2 files changed, 69 insertions, 0 deletions
diff --git a/testing/examples/open-at-point.org b/testing/examples/open-at-point.org
new file mode 100644
index 0000000..b3bb92d
--- a/dev/null
+++ b/testing/examples/open-at-point.org
@@ -0,0 +1,8 @@
+
+* Header 1
+ :PROPERTIES:
+ :ID: header1_with_great_id
+ :END:
+* Header 2
+ [[id:header1_with_great_id][Header 1]]
+ id:header1_with_great_id
diff --git a/testing/lisp/test-org-open-at-point.el b/testing/lisp/test-org-open-at-point.el
new file mode 100644
index 0000000..78724c8
--- a/dev/null
+++ b/testing/lisp/test-org-open-at-point.el
@@ -0,0 +1,61 @@
+;;; test-org-open-at-point.el
+
+;; Copyright (c) Samuel Loury
+;; Authors: Samuel Loury
+
+;; Released under the GNU General Public License version 3
+;; see: http://www.gnu.org/licenses/gpl-3.0.html
+
+;;;; Comments:
+
+;; Test for the org-open-at-point function
+
+;;; Code:
+
+(save-excursion
+ (set-buffer (get-buffer-create "test-org-open-at-point.el"))
+ (setq ly-here
+ (file-name-directory
+ (or load-file-name (buffer-file-name)))))
+
+(defun test-org-open-at-point/goto-fixture ()
+ (find-file-other-window
+ (concat ly-here "../examples/open-at-point.org"))
+ (set-buffer "open-at-point.org"))
+
+(ert-deftest test-org-open-at-point/bracket-link-inside ()
+ "Test `org-open-at-point' from inside a bracket link."
+ (test-org-open-at-point/goto-fixture)
+ ;; go inside the bracket link
+ (goto-char 113)
+ (org-open-at-point)
+ ;; should now be in front of the header
+ (should (equal (point) 2)))
+
+(ert-deftest test-org-open-at-point/plain-link-inside ()
+ "Test `org-open-at-point' from inside a plain link."
+ (test-org-open-at-point/goto-fixture)
+ ;; go inside the plain link
+ (goto-char 126)
+ (org-open-at-point)
+ ;; should now be in front of the header
+ (should (equal (point) 2)))
+
+(ert-deftest test-org-open-at-point/bracket-link-before ()
+ "Test `org-open-at-point' from before a bracket link but in the same line."
+ (test-org-open-at-point/goto-fixture)
+ ;; go before the bracket link
+ (goto-char 83)
+ (message "point %s" (point))
+ (org-open-at-point)
+ ;; should now be in front of the header
+ (should (equal (point) 2)))
+
+(ert-deftest test-org-open-at-point/plain-link-before ()
+ "Test `org-open-at-point' from before a plain link but in the same line."
+ (test-org-open-at-point/goto-fixture)
+ ;; go before the plain link
+ (goto-char 124)
+ (org-open-at-point)
+ ;; should now be in front of the header
+ (should (equal (point) 2)))