]> code.delx.au - gnu-emacs-elpa/blobdiff - ivy-test.el
Fix remapping commit c9b6e0
[gnu-emacs-elpa] / ivy-test.el
index 807f8ada4f2bd3f1a1d53505b8b9c739da0209a4..a654ad62e8f9578c5e00a4e980477b48dc883b9e 100644 (file)
 ;; see <http://www.gnu.org/licenses/>.
 
 (require 'ert)
+
+;; useful for #'ivy-read-remap. It must arrive before (require 'ivy)
+(define-key global-map (kbd "<S-right>") #'end-of-buffer)
+
 (require 'ivy)
 (require 'counsel)
 
                      "can C-m")
            "can")))
 
+(ert-deftest ivy-read-remap ()
+  (should (equal
+           (ivy-with '(ivy-read "pattern: " '("blue" "yellow" "red"))
+                  "<S-right> C-m")
+           "red")))
+
 (ert-deftest swiper--re-builder ()
   (setq swiper--width 4)
   (should (string= (swiper--re-builder "^")
                   "and  I  am"
                    "your  king."))))
 
+(ert-deftest ivy--regex ()
+  (should (equal (ivy--regex
+                  "\\(?:interactive\\|swiper\\) \\(?:list\\|symbol\\)")
+                 "\\(\\(?:interactive\\|swiper\\)\\).*?\\(\\(?:list\\|symbol\\)\\)")))
+
 (ert-deftest ivy--regex-fuzzy ()
   (should (string= (ivy--regex-fuzzy "tmux")
                    "\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
 
 (ert-deftest ivy--format ()
   (should (string= (let ((ivy--index 10)
-                         (ivy-format-function (lambda (x) (mapconcat (lambda (y) (car y)) x "\n")))
+                         (ivy-format-function (lambda (x) (mapconcat #'identity x "\n")))
                          (cands '("NAME"
                                   "SYNOPSIS"
                                   "DESCRIPTION"
 (ert-deftest counsel-unquote-regex-parens ()
   (should (equal (counsel-unquote-regex-parens
                   (ivy--regex "foo bar"))
-                 "(foo).*?(bar)")))
+                 "(foo).*?(bar)"))
+  (should (equal (counsel-unquote-regex-parens
+                  (ivy--regex "(foo bar"))
+                 "(\\(foo).*?(bar)")))