]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/company/test/bbdb-tests.el
Merge commit '212c8fc3101781a2f1c55ca61772eb75a2046e87' from company
[gnu-emacs-elpa] / packages / company / test / bbdb-tests.el
diff --git a/packages/company/test/bbdb-tests.el b/packages/company/test/bbdb-tests.el
new file mode 100644 (file)
index 0000000..b1f21b9
--- /dev/null
@@ -0,0 +1,46 @@
+;;; bbdb-tests.el --- company-mode tests  -*- lexical-binding: t -*-
+
+;; Copyright (C) 2016  Free Software Foundation, Inc.
+
+;; Author: Dmitry Gutov
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+(require 'company-tests)
+(require 'company-bbdb)
+
+(provide 'bbdb-com)
+
+(ert-deftest company-bbdb-prefix-looks-in-header-value ()
+  (with-temp-buffer
+    (insert "To: J")
+    (setq-local major-mode 'message-mode)
+    (should (equal (company-bbdb 'prefix)
+                   "J"))))
+
+(ert-deftest company-bbdb-prefix-includes-space ()
+  (with-temp-buffer
+    (insert "To: John Sm")
+    (setq-local major-mode 'message-mode)
+    (should (equal (company-bbdb 'prefix)
+                   "John Sm"))))
+
+(ert-deftest company-bbdb-prefix-begins-after-comma-or-semi ()
+  (with-temp-buffer
+    (insert "To: John Smythe <jsm@y.the>, Jess C")
+    (setq-local major-mode 'message-mode)
+    (should (equal (company-bbdb 'prefix)
+                   "Jess C"))))