|
1 | 1 | (ns cider.nrepl.middleware.apropos-test
|
2 | 2 | (:require
|
3 |
| - [cider.nrepl.middleware.apropos :refer [apropos]] |
| 3 | + [cider.nrepl.middleware.apropos :refer [apropos] :as apropos] |
4 | 4 | [cider.nrepl.test-session :as session]
|
5 | 5 | [clojure.string :as str]
|
6 | 6 | [clojure.test :refer :all]))
|
|
9 | 9 |
|
10 | 10 | (use-fixtures :each session/session-fixture)
|
11 | 11 |
|
| 12 | +(deftest msg->var-query-map-test |
| 13 | + (testing "Constructs the ns-query map correctly" |
| 14 | + (let [msg {:exclude-regexps ["^cider.nrepl" "^refactor-nrepl" "^nrepl"] |
| 15 | + :query "spelling"} |
| 16 | + query-map (#'apropos/msg->var-query-map msg)] |
| 17 | + (is (contains? (:var-query query-map) :ns-query)) |
| 18 | + (is (= 3 (count (-> query-map :var-query :ns-query :exclude-regexps))))))) |
| 19 | + |
12 | 20 | (deftest integration-test
|
13 | 21 | (testing "Apropos op, typical case"
|
14 | 22 | (let [response (session/message {:op "apropos" :query "handle-apropos"})
|
|
17 | 25 | (is (= (:type match) "function"))
|
18 | 26 | (is (= (:name match) "cider.nrepl.middleware.apropos/handle-apropos"))))
|
19 | 27 |
|
| 28 | + (testing "Exclude namespaces typical case" |
| 29 | + (let [response (session/message {:op "apropos" :query "handle-apropos" |
| 30 | + :exclude-regexps ["cider.nrepl.middleware.apropos"]}) |
| 31 | + match (get-in response [:apropos-matches 0])] |
| 32 | + (is (empty? match)) |
| 33 | + (is (= (:status response) #{"done"})))) |
| 34 | + |
20 | 35 | (testing "Apropos op, but specialized cases (invoked with prefix argument)"
|
21 | 36 | (testing "Fails to get a private var because private? unset"
|
22 | 37 | (let [response (session/message {:op "apropos" :query "my-private-var"})
|
|
0 commit comments