emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/which-key c011b26 5/9: Add tests for keymap-based-bindi


From: Stefan Monnier
Subject: [elpa] externals/which-key c011b26 5/9: Add tests for keymap-based-bindings
Date: Mon, 15 Mar 2021 22:29:20 -0400 (EDT)

branch: externals/which-key
commit c011b268196b8356c70f668506a1133086bc9477
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>

    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]