summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordpsutton <dpsutton@users.noreply.github.com>2018-01-03 08:52:31 -0600
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-01-03 16:52:31 +0200
commitc5d4964961ffbd321afd72bea6cac2a8c7133463 (patch)
treec9030c91b4868e268db3582dee3c22bbea736082 /test
parentf7079555b39f1506b7296ecdacd824ad1ec9ab87 (diff)
[Fix #1913] Allow toggling of current buffer connection (#2149)
Cljc buffers send their evals to both clj and cljs repls if available due to `cider-map-connections`. Toggling a current buffer's connection involves hiding the other connection. Previously, when toggling _again_, the original list was not consulted and only the truncated list, preventing the other connection from being found. This allows for the full list to be searched for the other buffer. In addition, a prefix dictates that the local connection list is discarded in favor of the full list, restoring the evaluation in both clj and cljs buffers (if both are present).
Diffstat (limited to 'test')
-rw-r--r--test/cider-client-tests.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/cider-client-tests.el b/test/cider-client-tests.el
index b6f56169..82cf6654 100644
--- a/test/cider-client-tests.el
+++ b/test/cider-client-tests.el
@@ -235,6 +235,46 @@
:to-equal "stub")
(expect (cider-var-info "") :to-equal nil)))
+(describe "cider-toggle-buffer-connection"
+ (spy-on 'message :and-return-value nil)
+
+ (describe "when there are multiple connections"
+ (it "toggles between multiple buffers"
+ (with-connection-buffer "clj" clj-buffer
+ (with-connection-buffer "cljs" cljs-buffer
+ (with-temp-buffer
+ (setq major-mode 'clojurec-mode)
+ (expect (cider-connections)
+ :to-equal (list cljs-buffer clj-buffer))
+
+ (cider-toggle-buffer-connection)
+ (expect (cider-connections)
+ :to-equal (list clj-buffer))
+
+ (cider-toggle-buffer-connection)
+ (expect (cider-connections)
+ :to-equal (list cljs-buffer))
+
+ (cider-toggle-buffer-connection t)
+ (expect (cider-connections)
+ :to-equal (list cljs-buffer clj-buffer)))))))
+
+ (describe "when there is a single connection"
+ (it "reports a user error"
+ (with-connection-buffer "clj" clj-buffer
+ (with-temp-buffer
+ (setq major-mode 'clojurec-mode)
+ (expect (cider-connections)
+ :to-equal (list clj-buffer))
+
+ (expect (cider-toggle-buffer-connection) :to-throw 'user-error)
+
+ (expect (cider-connections)
+ :to-equal (list clj-buffer))
+
+ (expect (local-variable-p 'cider-connections)
+ :to-be nil))))))
+
(describe "cider-make-connection-default"
:var (connections)