]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/swiper/ivy-test.el
Merge commit '09f86fca437f1b2e168093824e9d4ee0aea5130a' from swiper
[gnu-emacs-elpa] / packages / swiper / ivy-test.el
index 91e0dc35d962cbc820cacfd8cbc804849dc0d74b..10dd8f98400516b90c6a55d84c7143bbf38fc34f 100644 (file)
                  '("We're all Britons"
                   "and  I  am"
                    "your  king."))))
+
+(ert-deftest ivy--regex-fuzzy ()
+  (should (string= (ivy--regex-fuzzy "tmux")
+                   "t.*m.*u.*x"))
+  (should (string= (ivy--regex-fuzzy "^tmux")
+                   "^t.*m.*u.*x"))
+  (should (string= (ivy--regex-fuzzy "^tmux$")
+                   "^t.*m.*u.*x$"))
+  (should (string= (ivy--regex-fuzzy "")
+                   ""))
+  (should (string= (ivy--regex-fuzzy "^")
+                   "^"))
+  (should (string= (ivy--regex-fuzzy "$")
+                   "$")))
+
+(ert-deftest ivy--format ()
+  (should (string= (let ((ivy--index 10)
+                         (ivy-format-function (lambda (x) (mapconcat #'identity x "\n")))
+                         (cands '("NAME"
+                                  "SYNOPSIS"
+                                  "DESCRIPTION"
+                                  "FUNCTION LETTERS"
+                                  "SWITCHES"
+                                  "DIAGNOSTICS"
+                                  "EXAMPLE 1"
+                                  "EXAMPLE 2"
+                                  "EXAMPLE 3"
+                                  "SEE ALSO"
+                                  "AUTHOR")))
+                     (ivy--format cands))
+                   #("\nDESCRIPTION\nFUNCTION LETTERS\nSWITCHES\nDIAGNOSTICS\nEXAMPLE 1\nEXAMPLE 2\nEXAMPLE 3\nSEE ALSO\nAUTHOR"
+                     0 90 (read-only nil)
+                     90 96 (face ivy-current-match read-only nil)))))
+
+(ert-deftest ivy--filter ()
+  (setq ivy-last (make-ivy-state))
+  (should (equal (ivy--filter "the" '("foo" "the" "The"))
+                 '("the" "The")))
+  (should (equal (ivy--filter "The" '("foo" "the" "The"))
+                 '("The"))))
+