summaryrefslogtreecommitdiff
path: root/test/cider-selector-tests.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@tradeo.com>2013-10-28 14:47:24 +0200
committerBozhidar Batsov <bozhidar@tradeo.com>2013-10-28 14:47:24 +0200
commitd946841f3c96af79c06d8424e02884bef249b18e (patch)
tree814328a18845c5ba000ac27a179c082c0887539d /test/cider-selector-tests.el
parent4a1e71b429da61bc35bc40151c7dd20bef45f480 (diff)
Extract cider-selector tests into a separate file
Diffstat (limited to 'test/cider-selector-tests.el')
-rw-r--r--test/cider-selector-tests.el57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/cider-selector-tests.el b/test/cider-selector-tests.el
new file mode 100644
index 00000000..9b2861e5
--- /dev/null
+++ b/test/cider-selector-tests.el
@@ -0,0 +1,57 @@
+(require 'cider)
+(require 'cider-selector)
+
+;; selector
+(defun cider-invoke-selector-method-by-key (ch)
+ (lexical-let ((method (find ch cider-selector-methods :key #'car)))
+ (funcall (third method))))
+
+(ert-deftest test-cider-selector-n ()
+ (with-temp-buffer
+ (lexical-let ((b1 (current-buffer)))
+ (set (make-local-variable 'cider-endpoint) '("123.123.123.123" 4006))
+ (let ((nrepl-connection-list (list (buffer-name b1))))
+ (nrepl-connection-browser)
+ (with-temp-buffer ;; switch to another buffer
+ (cider-invoke-selector-method-by-key ?n)
+ (should (equal (current-buffer)
+ (get-buffer nrepl--connection-browser-buffer-name))))))))
+
+(ert-deftest test-cider-selector-c ()
+ (with-temp-buffer
+ (rename-buffer "*testfile*.clj")
+ (lexical-let ((b1 (current-buffer)))
+ (setq major-mode 'clojure-mode)
+ (with-temp-buffer
+ (rename-buffer "*testfile*.el")
+ (setq major-mode 'emacs-lisp-mode)
+ (with-temp-buffer
+ (should (not (equal (current-buffer) b1)))
+ (cider-invoke-selector-method-by-key ?e)
+ (should (not (equal (current-buffer) b1)))
+ (cider-invoke-selector-method-by-key ?c)
+ (should (equal (current-buffer) b1)))))))
+
+(ert-deftest test-cider-selector-e ()
+ (with-temp-buffer
+ (rename-buffer "*testfile*.el")
+ (lexical-let ((b1 (current-buffer)))
+ (setq major-mode 'emacs-lisp-mode)
+ (with-temp-buffer
+ (rename-buffer "*testfile*.clj")
+ (setq major-mode 'clojure-mode)
+ (with-temp-buffer
+ (should (not (equal (current-buffer) b1)))
+ (cider-invoke-selector-method-by-key ?c)
+ (should (not (equal (current-buffer) b1)))
+ (cider-invoke-selector-method-by-key ?e)
+ (should (equal (current-buffer) b1)))))))
+
+(ert-deftest test-cider-selector-v ()
+ (with-temp-buffer
+ (rename-buffer "*nrepl-events*")
+ (lexical-let ((b1 (current-buffer)))
+ (with-temp-buffer
+ (should (not (equal (current-buffer) b1)))
+ (cider-invoke-selector-method-by-key ?v)
+ (should (equal (current-buffer) b1))))))