]> code.delx.au - gnu-emacs-elpa/commitdiff
Add two tests for company-auto-complete
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 24 Mar 2013 22:53:49 +0000 (02:53 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 24 Mar 2013 22:53:49 +0000 (02:53 +0400)
company-tests.el

index fd89b58ece793db75a8ee8b5f8cc84bd7f3262d3..ee477e7c5940ecb1890c88b9dee1b33f5cd3c61c 100644 (file)
@@ -96,7 +96,7 @@
       (should (eq 2 company-candidates-length))
       (should (eq 3 (point))))))
 
-(ert-deftest company-dont-require-match-idle ()
+(ert-deftest company-dont-require-match-when-idle ()
   (with-temp-buffer
     (insert "ab")
     (company-mode)
       (company-post-command)
       (should (eq nil company-candidates-length))
       (should (eq 4 (point))))))
+
+(ert-deftest company-auto-complete-explicit ()
+  (with-temp-buffer
+    (insert "ab")
+    (company-mode)
+    (let (company-frontends
+          (company-auto-complete 'company-explicit-action-p)
+          (company-auto-complete-chars '(? ))
+          (company-backends
+           (list (lambda (command &optional arg)
+                   (case command
+                     (prefix (buffer-substring (point-min) (point)))
+                     (candidates '("abcd" "abef")))))))
+      (let (this-command)
+        (company-complete))
+      (let ((last-command-event ? ))
+        (self-insert-command 1))
+      (company-post-command)
+      (should (string= "abcd " (buffer-string))))))
+
+(ert-deftest company-no-auto-complete-when-idle ()
+  (with-temp-buffer
+    (insert "ab")
+    (company-mode)
+    (let (company-frontends
+          (company-auto-complete 'company-explicit-action-p)
+          (company-auto-complete-chars '(? ))
+          (company-backends
+           (list (lambda (command &optional arg)
+                   (case command
+                     (prefix (buffer-substring (point-min) (point)))
+                     (candidates '("abcd" "abef")))))))
+      (company-idle-begin (current-buffer) (selected-window)
+                          (buffer-chars-modified-tick) (point))
+      (let ((last-command-event ? ))
+        (self-insert-command 1))
+      (company-post-command)
+      (should (string= "ab " (buffer-string))))))