branch: externals/which-key
commit c011b268196b8356c70f668506a1133086bc9477
Author: Justin Burkett <[email protected]>
Commit: Justin Burkett <[email protected]>
Add tests for keymap-based-bindings
---
which-key-tests.el | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/which-key-tests.el b/which-key-tests.el
index f9fac65..1611d51 100644
--- a/which-key-tests.el
+++ b/which-key-tests.el
@@ -27,7 +27,24 @@
(require 'which-key)
(require 'ert)
-(ert-deftest which-key-test-prefix-declaration ()
+(ert-deftest which-key-test--keymap-based-bindings ()
+ (let ((map (make-sparse-keymap))
+ (emacs-lisp-mode-map (copy-keymap emacs-lisp-mode-map)))
+ (emacs-lisp-mode)
+ (define-key map "x" 'ignore)
+ (define-key emacs-lisp-mode-map "\C-c\C-a" 'complete)
+ (define-key emacs-lisp-mode-map "\C-c\C-b" map)
+ (which-key-add-keymap-based-replacements emacs-lisp-mode-map
+ "C-c C-a" '("mycomplete" . complete)
+ "C-c C-b" "mymap")
+ (should (equal
+ (which-key--maybe-replace '("C-c C-a" . "complete"))
+ '("C-c C-a" . "mycomplete")))
+ (should (equal
+ (which-key--maybe-replace '("C-c C-b" . ""))
+ '("C-c C-b" . "mymap")))))
+
+(ert-deftest which-key-test--prefix-declaration ()
"Test `which-key-declare-prefixes' and
`which-key-declare-prefixes-for-mode'. See Bug #109."
(let* ((major-mode 'test-mode)