|
69 | 69 | (expect (cider--eldoc-format-class-names class-names)
|
70 | 70 | :to-equal "(String StringBuffer CharSequence & 1 more)")))))
|
71 | 71 |
|
| 72 | +(describe "cider-eldoc-thing-type" |
| 73 | + (it "Identifies special forms correctly" |
| 74 | + (let ((eldoc-info '("type" "special-form"))) |
| 75 | + (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'special-form))) |
| 76 | + (it "Identifies functions correctly" |
| 77 | + (let ((eldoc-info '("type" "function"))) |
| 78 | + (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'fn)))) |
| 79 | + |
| 80 | +(describe "cider-eldoc-format-special-form" |
| 81 | + (before-each |
| 82 | + (spy-on 'cider-eldoc-format-thing :and-return-value "formatted thing!") |
| 83 | + (spy-on 'cider-eldoc-format-arglist :and-return-value "formatted arglist!")) |
| 84 | + (it "Should remove duplicates from special-form arglists that have duplicates" |
| 85 | + (let ((eldoc-info '("ns" nil |
| 86 | + "symbol" "if" |
| 87 | + "arglists" (("if" "test" "then" "else?")) |
| 88 | + "type" "special-form"))) |
| 89 | + (cider-eldoc-format-special-form 'if 0 eldoc-info) |
| 90 | + (expect 'cider-eldoc-format-arglist :to-have-been-called-with '(("test" "then" "else?")) 0))) |
| 91 | + (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 | + (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 | + |
72 | 103 | (describe "cider-eldoc-format-thing"
|
73 | 104 | :var (class-names)
|
74 | 105 | (before-each
|
|
238 | 269 | (expect (cider-eldoc-info-in-current-sexp) :to-equal
|
239 | 270 | '("eldoc-info" (("java.lang.String") ".length" (("this"))) "thing" "java.lang.String/.length" "pos" 0)))))))
|
240 | 271 |
|
| 272 | +(describe "cider-eldoc" |
| 273 | + (before-each |
| 274 | + (spy-on 'cider-connected-p :and-return-value t) |
| 275 | + (spy-on 'cider-eldoc--edn-file-p :and-return-value nil)) |
| 276 | + (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"))) |
| 281 | + (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")))) |
| 286 | + (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")))) |
| 291 | + (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"))))) |
| 296 | + |
241 | 297 | (describe "cider-eldoc-format-sym-doc"
|
242 | 298 | :var (eldoc-echo-area-use-multiline-p)
|
243 | 299 | (before-each
|
|
0 commit comments