|
69 | 69 | (expect (cider--eldoc-format-class-names class-names) |
70 | 70 | :to-equal "(String StringBuffer CharSequence & 1 more)"))))) |
71 | 71 |
|
| 72 | +;; NOTE: more cases could be added. Correct behavior is TBD, see https://github.com/clojure-emacs/orchard/issues/99 |
72 | 73 | (describe "cider-eldoc-thing-type" |
73 | 74 | (it "Identifies special forms correctly" |
74 | 75 | (let ((eldoc-info '("type" "special-form"))) |
75 | 76 | (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'special-form))) |
76 | 77 | (it "Identifies functions correctly" |
77 | 78 | (let ((eldoc-info '("type" "function"))) |
| 79 | + (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'fn))) |
| 80 | + (it "Defaults to 'fn" |
| 81 | + (let ((eldoc-info '("type" "made-up-123"))) |
78 | 82 | (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'fn)))) |
79 | 83 |
|
80 | 84 | (describe "cider-eldoc-format-special-form" |
|
89 | 93 | (cider-eldoc-format-special-form 'if 0 eldoc-info) |
90 | 94 | (expect 'cider-eldoc-format-arglist :to-have-been-called-with '(("test" "then" "else?")) 0))) |
91 | 95 | (it "Should not remove duplicates from special-form arglists that do not have duplicates" |
92 | | - (let ((eldoc-info '("ns" nil |
93 | | - "symbol" "." |
94 | | - "arglists" ((".instanceMember" "instance" "args*") (".instanceMember" "Classname" "args*") ("Classname/staticMethod" "args*") ("Classname/staticField")) |
95 | | - "type" "special-form"))) |
| 96 | + (let* ((arglists '((".instanceMember" "instance" "args*") (".instanceMember" "Classname" "args*") ("Classname/staticMethod" "args*") ("Classname/staticField"))) |
| 97 | + (eldoc-info `("ns" nil |
| 98 | + "symbol" "." |
| 99 | + "arglists" ,arglists |
| 100 | + "type" "special-form"))) |
96 | 101 | (cider-eldoc-format-special-form 'if 0 eldoc-info) |
97 | | - (expect 'cider-eldoc-format-arglist :to-have-been-called-with '((".instanceMember" "instance" "args*") |
98 | | - (".instanceMember" "Classname" "args*") |
99 | | - ("Classname/staticMethod" "args*") |
100 | | - ("Classname/staticField")) |
101 | | - 0)))) |
| 102 | + (expect 'cider-eldoc-format-arglist :to-have-been-called-with arglists 0)))) |
102 | 103 |
|
103 | 104 | (describe "cider-eldoc-format-thing" |
104 | 105 | :var (class-names) |
|
274 | 275 | (spy-on 'cider-connected-p :and-return-value t) |
275 | 276 | (spy-on 'cider-eldoc--edn-file-p :and-return-value nil)) |
276 | 277 | (it "Should call cider-eldoc-format-variable for vars" |
277 | | - (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" "foo" "pos" 0 "eldoc-info" ("ns" "clojure.core" "symbol" "foo" "type" "variable" "docstring" "test docstring"))) |
278 | | - (spy-on 'cider-eldoc-format-variable) |
279 | | - (cider-eldoc) |
280 | | - (expect 'cider-eldoc-format-variable :to-have-been-called-with "foo" '("ns" "clojure.core" "symbol" "foo" "type" "variable" "docstring" "test docstring"))) |
| 278 | + (let* ((info '("ns" "clojure.core" "symbol" "foo" "type" "variable" "docstring" "test docstring"))) |
| 279 | + (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" "foo" "pos" 0 "eldoc-info" ,info)) |
| 280 | + (spy-on 'cider-eldoc-format-variable) |
| 281 | + (cider-eldoc) |
| 282 | + (expect 'cider-eldoc-format-variable :to-have-been-called-with "foo" info))) |
| 283 | + |
281 | 284 | (it "Should call cider-eldoc-format-special-form for special forms" |
282 | | - (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" "if" "pos" 0 "eldoc-info" ("ns" "clojure.core" "symbol" "if" "type" "special-form" "arglists" ("special form arglist")))) |
283 | | - (spy-on 'cider-eldoc-format-special-form) |
284 | | - (cider-eldoc) |
285 | | - (expect 'cider-eldoc-format-special-form :to-have-been-called-with "if" 0 '("ns" "clojure.core" "symbol" "if" "type" "special-form" "arglists" ("special form arglist")))) |
| 285 | + (let* ((info '("ns" "clojure.core" "symbol" "if" "type" "special-form" "arglists" ("special form arglist")))) |
| 286 | + (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" "if" "pos" 0 "eldoc-info" ,info)) |
| 287 | + (spy-on 'cider-eldoc-format-special-form) |
| 288 | + (cider-eldoc) |
| 289 | + (expect 'cider-eldoc-format-special-form :to-have-been-called-with "if" 0 info))) |
| 290 | + |
286 | 291 | (it "Should call cider-eldoc-format-function for functions" |
287 | | - (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" "a-fn" "pos" 0 "eldoc-info" ("ns" "foo.bar" "symbol" "a-fn" "type" "function" "arglists" ("function arglist")))) |
288 | | - (spy-on 'cider-eldoc-format-function) |
289 | | - (cider-eldoc) |
290 | | - (expect 'cider-eldoc-format-function :to-have-been-called-with "a-fn" 0 '("ns" "foo.bar" "symbol" "a-fn" "type" "function" "arglists" ("function arglist")))) |
| 292 | + (let* ((info '("ns" "foo.bar" "symbol" "a-fn" "type" "function" "arglists" ("function arglist")))) |
| 293 | + (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" "a-fn" "pos" 0 "eldoc-info" ,info)) |
| 294 | + (spy-on 'cider-eldoc-format-function) |
| 295 | + (cider-eldoc) |
| 296 | + (expect 'cider-eldoc-format-function :to-have-been-called-with "a-fn" 0 info))) |
| 297 | + |
291 | 298 | (it "Should call cider-eldoc-format-function for macros" |
292 | | - (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" "a-macro" "pos" 0 "eldoc-info" ("ns" "clojure.core" "symbol" "a-macro" "type" "macro" "arglists" ("macro arglist")))) |
293 | | - (spy-on 'cider-eldoc-format-function) |
294 | | - (cider-eldoc) |
295 | | - (expect 'cider-eldoc-format-function :to-have-been-called-with "a-macro" 0 '("ns" "clojure.core" "symbol" "a-macro" "type" "macro" "arglists" ("macro arglist"))))) |
| 299 | + (let* ((info '("ns" "clojure.core" "symbol" "a-macro" "type" "macro" "arglists" ("macro arglist")))) |
| 300 | + (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" "a-macro" "pos" 0 "eldoc-info" ,info)) |
| 301 | + (spy-on 'cider-eldoc-format-function) |
| 302 | + (cider-eldoc) |
| 303 | + (expect 'cider-eldoc-format-function :to-have-been-called-with "a-macro" 0 info)))) |
296 | 304 |
|
297 | 305 | (describe "cider-eldoc-format-sym-doc" |
298 | 306 | :var (eldoc-echo-area-use-multiline-p) |
|
364 | 372 | (it "adds the datomic query inputs of the query at point to the arglist" |
365 | 373 | (spy-on 'cider-second-sexp-in-list :and-return-value t) |
366 | 374 | (spy-on 'cider-sync-request:eldoc-datomic-query |
367 | | - :and-return-value '(dict "inputs" (("$" "?first-name")))) |
| 375 | + :and-return-value '(dict "inputs" (("$" "?first-name")))) |
368 | 376 | (expect (cider--eldoc-add-datomic-query-inputs-to-arglists '(("query" "&" "inputs"))) |
369 | 377 | :to-equal '(("query" "$" "?first-name"))))) |
0 commit comments