test-org-open-at-point.el 1.8 KB

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