Skip to content

Commit

Permalink
test: Add tests for elin.nrepl.connection/connect
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Jan 22, 2024
1 parent c704a8f commit 3a92679
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/elin/nrepl/connection_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(ns elin.nrepl.connection-test
(:require
[clojure.core.async :as async]
[clojure.test :as t]
[elin.nrepl.connection]
[elin.nrepl.message :as e.n.message]
[elin.protocol.nrepl :as e.p.nrepl]
[elin.test-helper :as h]))

(t/use-fixtures :once h/malli-instrument-fixture)
(t/use-fixtures :each h/test-nrepl-connection-fixture)

(t/deftest connect-test
(let [conn h/*nrepl-connection*]
(t/is (false? (e.p.nrepl/disconnected? conn)))

(t/testing "request"
(let [resp (-> (e.p.nrepl/request conn {:op "describe"})
(async/<!!)
(e.n.message/merge-messages))]
(t/is (= #{:babashka :babashka.nrepl}
(set (keys (:versions resp)))))))

(t/testing "notify and std out"
(let [resp (e.p.nrepl/notify conn {:op "eval" :code "(println \"hello\")"})]
(t/is (nil? resp))
(async/<!! (async/timeout 100))
(t/is (= {:type "out" :text "hello\n"}
(async/<!! (:output-channel conn))))))

;; TODO
(t/testing "pprint-out")
(t/testing "std err")

(t/testing "disconnect"
(t/is (true? (e.p.nrepl/disconnect conn)))
(t/is (true? (e.p.nrepl/disconnected? conn))))))

0 comments on commit 3a92679

Please sign in to comment.