branch: elpa/bind-map
commit 8d6b489feb3e7c07ad95e9dac383ddafad47abfa
Author: justbur <[email protected]>
Commit: justbur <[email protected]>
Add some basic tests
---
bind-map-tests.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/bind-map-tests.el b/bind-map-tests.el
new file mode 100644
index 0000000000..bcb806307c
--- /dev/null
+++ b/bind-map-tests.el
@@ -0,0 +1,51 @@
+;;; bind-map-tests.el
+
+;; Copyright (C) 2015 Justin Burkett
+
+;; Author: Justin Burkett <[email protected]>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(require 'bind-map)
+(require 'evil)
+
+(ert-deftest bind-map-test-global-keys ()
+ "Test binding in global maps."
+ (let ((map (make-sparse-keymap)))
+ (bind-map map
+ :keys ("C-a")
+ :evil-keys ("a")
+ :evil-states (motion))
+ (define-key map "a" "b")
+ (should (keymapp (lookup-key global-map "\C-a")))
+ (should (string= (lookup-key global-map "\C-aa") "b"))
+ (should (keymapp (lookup-key evil-motion-state-map "a")))
+ (should (string= (lookup-key evil-motion-state-map "aa") "b"))
+ (should (not (string= (lookup-key evil-visual-state-map "aa") "b")))))
+
+(ert-deftest bind-map-test-minor-mode-keys ()
+ "Test binding for minor-modes."
+ (let ((map (make-sparse-keymap))
+ (map-root-map (make-sparse-keymap))
+ (fake-minor-mode t)
+ minor-mode-map-alist)
+ (bind-map map
+ :minor-modes (fake-minor-mode)
+ :keys ("C-a")
+ :evil-keys ("a")
+ :evil-states (motion))
+ (define-key map "a" "b")
+ (should (string= (key-binding "\C-aa") "b"))
+ (should (keymapp (lookup-key (evil-get-auxiliary-keymap map-root-map
'motion) "a")))
+ (should (string= (lookup-key (evil-get-auxiliary-keymap map-root-map
'motion) "aa") "b"))))