[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 01e8a2b: Add org mode tests (#73)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 01e8a2b: Add org mode tests (#73) |
Date: |
Tue, 27 Apr 2021 02:57:07 -0400 (EDT) |
branch: externals/hyperbole
commit 01e8a2b3853368f764a96a9407e43322092ddde4
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>
Add org mode tests (#73)
---
Changes | 27 ++++++++++-
hsys-org.el | 8 ++--
test/hib-org-tests.el | 76 +++++++++++++++++++++++++++++
test/hsys-org-tests.el | 125 ++++++++++++++++++++++++++++++++++++++++++++++++
test/hy-test-helpers.el | 9 ++++
5 files changed, 241 insertions(+), 4 deletions(-)
diff --git a/Changes b/Changes
index f42c719..7a1507f 100644
--- a/Changes
+++ b/Changes
@@ -16,12 +16,37 @@
structure and expanded classes of excluded chars to prevent spurious path
matches by hpath:delimited-possible-path.
-
* hui-mini.el (hyperbole): Enable hyperbole-mode when invoked with {C-h h}.
* hyperbole.el (hyperbole-help-map, hkey-help-set-key): Add to set help keys
available only when Hyperbole is enabled.
+2021-04-26 Mats Lidell <matsl@gnu.org>
+
+* test/hib-org-tests.el
(hib-org:org-mode-with-smart-keys-on-file-is-hypb-button)
+ (hib-org:org-mode-with-smart-keys-buttons-on-file-is-hypb-button)
+ (hib-org:org-mode-with-no-smart-keys-on-file-is-hypb-button): Tests for
+ hsys-org-enable-smart-keys.
+
+* test/hy-test-helpers.el
+ (hy-test-helpers:hypb-function-should-call-hpath:find): Test helper to
+ verify any hypb function that should call hpath:find
+
+2021-04-25 Mats Lidell <matsl@gnu.org>
+
+* test/hsys-org-tests.el (hsys-org:cycle-on-header-cycles-visibility)
+ (hsys-org:region-with-text-property-value, hsys-org:block-start-at-p)
+ (hsys-org:org-link-at-p, hsys-org:org-target-at-p)
+ (hsys-org:org-radio-target-link-at-p)
+ (hsys-org:org-radio-target-def-at-p, hsys-org:org-radio-target-at-p)
+ (hsys-org:org-internal-link-target-at-p, hsys-org:org-face-at-p): hsys-org
tests
+
+* test/hib-org-tests.el (hib-org:org-mode-on-header-cycles-visibility):
+ hib-org test
+
+* hsys-org.el (hsys-org-link-at-p): Use org-target-link-regexp for radio links
+ (hsys-org-internal-link-target-at-p): Inverse boolean check
+
2021-04-25 Bob Weiner <rsw@gnu.org>
* hyperbole.el (hkey-override-local-bindings,
diff --git a/hsys-org.el b/hsys-org.el
index 6bb6e7a..d362fe6 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -102,7 +102,9 @@ or are looking for an Org link in another buffer type."
(org-in-regexp org-link-bracket-re))
(and (boundp 'org-bracket-link-regexp)
(org-in-regexp org-bracket-link-regexp))
- (hsys-org-face-at-p 'org-link)))
+ (and (boundp 'org-target-link-regexp)
+ (not (null org-target-link-regexp))
+ (org-in-regexp org-target-link-regexp))))
;; Assumes caller has already checked that the current buffer is in org-mode.
(defun hsys-org-target-at-p ()
@@ -139,8 +141,8 @@ Assumes caller has already checked that the current buffer
is in `org-mode'."
(goto-char (or (previous-single-property-change (point) 'face)
(point-min))))
(when (looking-at "<<<?")
(goto-char (match-end 0)))
- (and (not (get-text-property (point) 'org-linked-text))
- (hsys-org-region-with-text-property-value (point) 'face)))))
+ (and (get-text-property (point) 'org-linked-text)
+ (hsys-org-region-with-text-property-value (point) 'face)))))
(defun hsys-org-face-at-p (org-face-type)
"Return ORG-FACE-TYPE iff point is on a character with face ORG-FACE-TYPE, a
symbol, else nil."
diff --git a/test/hib-org-tests.el b/test/hib-org-tests.el
new file mode 100644
index 0000000..1ea3942
--- /dev/null
+++ b/test/hib-org-tests.el
@@ -0,0 +1,76 @@
+;;; hib-org-tests.el --- hib-org-el tests -*- lexical-binding: t;
-*-
+
+;; Copyright (C) 2021 Mats Lidell
+
+;; Author: Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date: 23-Apr-21 at 22:21:00
+;;
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+
+;; Tests for "../hib-org.el"
+
+;;; Code:
+
+(require 'ert)
+(require 'hib-org)
+(require 'hact)
+
+(declare-function hy-test-helpers:hypb-function-should-call-hpath:find
"hy-test-helpers")
+
+(ert-deftest hib-org:org-mode-on-header-cycles-visibility ()
+ "With smart keys on an outline header `ibtypes::org-mode' cycles visibility."
+ (with-temp-buffer
+ (let ((bn (buffer-name))
+ (hsys-org-enable-smart-keys t))
+ (org-mode)
+ (insert "* 1\n** 2\n*** 3\n")
+ (goto-char 1)
+ (should (not (org-check-for-hidden 'headlines)))
+ (ibtypes::org-mode)
+ ;; Setting the buffer should not be needed but for some reason
+ ;; it looks like we get into ert buffer after ibtypes::org-mode
+ (set-buffer bn)
+ (should (org-check-for-hidden 'headlines))
+ (next-line)
+ (should (equal (line-number-at-pos) 4)))))
+
+(ert-deftest hib-org:org-mode-with-smart-keys-on-file-is-hypb-button ()
+ "With smart keys on file name is hypb button."
+ (with-temp-buffer
+ (let ((hsys-org-enable-smart-keys t))
+ (org-mode)
+ (insert "/tmp")
+ (goto-char 1)
+ (hy-test-helpers:hypb-function-should-call-hpath:find 'ibtypes::org-mode
"/tmp"))))
+
+(ert-deftest hib-org:org-mode-with-smart-keys-buttons-on-file-is-hypb-button ()
+ "With smart keys on file name is hypb button."
+ (with-temp-buffer
+ (let ((hsys-org-enable-smart-keys 'buttons))
+ (org-mode)
+ (insert "/tmp")
+ (goto-char 1)
+ (hy-test-helpers:hypb-function-should-call-hpath:find 'ibtypes::org-mode
"/tmp"))))
+
+(ert-deftest hib-org:org-mode-with-no-smart-keys-on-file-is-hypb-button ()
+ "With no smart keys on file calls org mode M-RET."
+ (with-temp-buffer
+ (let ((bn (buffer-name))
+ (hsys-org-enable-smart-keys nil))
+ (org-mode)
+ (insert "/tmp")
+ (goto-char 1)
+ (ibtypes::org-mode)
+ ;; Setting the buffer should not be needed but for some reason
+ ;; it looks like we get into ert buffer after ibtypes::org-mode
+ (set-buffer bn)
+ (should (equal (buffer-string) "* /tmp")))))
+
+(provide 'hib-org-tests)
+;;; hib-org-tests.el ends here
diff --git a/test/hsys-org-tests.el b/test/hsys-org-tests.el
new file mode 100644
index 0000000..3566155
--- /dev/null
+++ b/test/hsys-org-tests.el
@@ -0,0 +1,125 @@
+;;; hsys-org-tests.el --- hsys-org tests -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Mats Lidell
+
+;; Author: Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date: 23-Apr-21 at 20:55:00
+;;
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+
+;; Tests for "../hsys-org.el"
+
+;;; Code:
+
+(require 'ert)
+(require 'hsys-org)
+(require 'el-mock)
+
+(ert-deftest hsys-org:cycle-on-header-cycles-visibility ()
+ "Hide an outline header."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* 1\n** 2\n*** 3\n")
+ (goto-char 1)
+ (should (not (org-check-for-hidden 'headlines)))
+ (hsys-org-cycle)
+ (should (org-check-for-hidden 'headlines))
+ (next-line)
+ (should (equal (line-number-at-pos) 4))))
+
+(ert-deftest hsys-org:region-with-text-property-value ()
+ "Should get the region with the specific text property."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* 1\n** 2\n*** 3\n")
+ (goto-char 1)
+ (font-lock-ensure)
+ (should (equal (hsys-org-region-with-text-property-value 1 'face) '(1 .
4)))))
+
+;; TODO: org-agenda-item-at-p
+
+(ert-deftest hsys-org:block-start-at-p ()
+ "Should be t if point is on the start of a block."
+ (with-temp-buffer
+ (org-mode)
+ (insert "#+BEGIN_BLK\n text\n#+END_BLK\n")
+ (goto-char 1)
+ (should (hsys-org-block-start-at-p))))
+
+(ert-deftest hsys-org:org-link-at-p ()
+ "Should be t if point is within an org-link."
+ (with-temp-buffer
+ (org-mode)
+ (insert "[[Link]]\n")
+ (goto-char 3)
+ (should (hsys-org-link-at-p))))
+
+(ert-deftest hsys-org:org-target-at-p ()
+ "Should be non nil if point is within an org-radio-target."
+ (with-temp-buffer
+ (org-mode)
+ (insert "<<<link>>>\n")
+ (goto-char 6)
+ (org-ctrl-c-ctrl-c)
+ (font-lock-ensure)
+ (should (hsys-org-target-at-p))))
+
+(ert-deftest hsys-org:org-radio-target-link-at-p ()
+ "Should return not nil if point is within an org radio target link."
+ (with-temp-buffer
+ (org-mode)
+ (insert " <<<link>>>\nlink\n")
+ (goto-char 6)
+ (org-ctrl-c-ctrl-c)
+ (font-lock-ensure)
+ (goto-char 16)
+ (should (equal (hsys-org-radio-target-link-at-p) '(13 . 17)))))
+
+(ert-deftest hsys-org:org-radio-target-def-at-p ()
+ "Should return (start . end) iff point is within an org radio target
definition."
+ (with-temp-buffer
+ (org-mode)
+ (insert " <<<link>>>\n")
+ (goto-char 6)
+ (org-ctrl-c-ctrl-c)
+ (font-lock-ensure)
+ (should (equal (hsys-org-radio-target-def-at-p) '(2 . 12)))))
+
+(ert-deftest hsys-org:org-radio-target-at-p ()
+ "Should return (start . end) iff point is within an org radio target
definition."
+ (with-temp-buffer
+ (org-mode)
+ (insert " <<<link>>>\nlink\n")
+ (goto-char 6)
+ (org-ctrl-c-ctrl-c)
+ (font-lock-ensure)
+ (should (equal (hsys-org-radio-target-at-p) '(2 . 12)))))
+
+(ert-deftest hsys-org:org-internal-link-target-at-p ()
+ "Should return (start . end) iff point is within an org radio target
definition."
+ (with-temp-buffer
+ (org-mode)
+ (insert " <<<link>>>\n")
+ (goto-char 6)
+ (org-ctrl-c-ctrl-c)
+ (font-lock-ensure)
+ (should (equal (hsys-org-internal-link-target-at-p) '(2 . 12)))))
+
+(ert-deftest hsys-org:org-face-at-p ()
+ "Should return face type iff point is within an org radio target definition."
+ (with-temp-buffer
+ (org-mode)
+ (insert " <<<link>>>\n")
+ (goto-char 6)
+ (org-ctrl-c-ctrl-c)
+ (font-lock-ensure)
+ (should (equal (hsys-org-face-at-p 'org-target) 'org-target))))
+
+(provide 'hsys-org-tests)
+;;; hsys-org-tests.el ends here
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index 28b6dfe..f38fea4 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -39,5 +39,14 @@
(action-key)
(should was-called))))
+(defun hy-test-helpers:hypb-function-should-call-hpath:find (function str)
+ "Call FUNCTION and check that hpath:find was called with STR."
+ (let ((was-called nil))
+ (cl-letf (((symbol-function 'hpath:find)
+ (lambda (filename)
+ (setq was-called (should (string= str filename))))))
+ (funcall function)
+ (should was-called))))
+
(provide 'hy-test-helpers)
;;; hy-test-helpers.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/hyperbole 01e8a2b: Add org mode tests (#73),
ELPA Syncer <=