|
34 | 34 | (it "opens without error" |
35 | 35 | (customize-group 'cider))) |
36 | 36 |
|
37 | | -;;; connection browser |
| 37 | +(describe "cider-figwheel-main-init-form" |
| 38 | + ;; whitespace checks sprinkled amongst other tests |
| 39 | + (describe "from options" |
| 40 | + (it "leaves keywords alone" |
| 41 | + (let ((cider-figwheel-main-default-options ":dev ")) |
| 42 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :dev))"))) |
| 43 | + (it "leaves maps alone" |
| 44 | + (let ((cider-figwheel-main-default-options " {:a 1 :b 2}")) |
| 45 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start {:a 1 :b 2}))"))) |
| 46 | + (it "leaves s-exprs alone" |
| 47 | + (let ((cider-figwheel-main-default-options " (hashmap :a 1 :b 2)")) |
| 48 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start (hashmap :a 1 :b 2)))"))) |
| 49 | + (it "prepends colon to plain names" |
| 50 | + (let ((cider-figwheel-main-default-options " dev")) |
| 51 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :dev))")))) |
| 52 | + |
| 53 | + (describe "from minibuffer" |
| 54 | + (before-each |
| 55 | + ;; not necessary as of this writing, but it can't hurt |
| 56 | + (setq-local cider-figwheel-main-default-options nil)) |
| 57 | + (it "leaves keywords alone" |
| 58 | + (spy-on 'read-from-minibuffer :and-return-value " :prod ") |
| 59 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :prod))")) |
| 60 | + (it "leaves maps alone" |
| 61 | + (spy-on 'read-from-minibuffer :and-return-value " {:c 3 :d 4}") |
| 62 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start {:c 3 :d 4}))")) |
| 63 | + (it "leaves s-exprs alone" |
| 64 | + (spy-on 'read-from-minibuffer :and-return-value "(keyword \"dev\") ") |
| 65 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start (keyword \"dev\")))")) |
| 66 | + (it "prepends colon to plain names" |
| 67 | + (spy-on 'read-from-minibuffer :and-return-value "prod ") |
| 68 | + (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :prod))")))) |
| 69 | + |
| 70 | +(describe "cider-project-type" |
| 71 | + (describe "when there is a single project" |
| 72 | + (it "returns that type" |
| 73 | + (spy-on 'cider--identify-buildtools-present |
| 74 | + :and-return-value '(lein)) |
| 75 | + (expect (cider-project-type) :to-equal 'lein))) |
| 76 | + |
| 77 | + (describe "when there are multiple possible project types" |
| 78 | + (before-all |
| 79 | + (spy-on 'cider--identify-buildtools-present |
| 80 | + :and-return-value '("build1" "build2")) |
| 81 | + ;; user choice build2 |
| 82 | + (spy-on 'completing-read :and-return-value "build2")) |
| 83 | + |
| 84 | + (it "returns the choice entered by user" |
| 85 | + (expect (cider-project-type) :to-equal "build2")) |
| 86 | + |
| 87 | + (it "respects the value of `cider-preferred-build-tool'" |
| 88 | + (let ((cider-preferred-build-tool "build1")) |
| 89 | + (expect (cider-project-type) :to-equal "build1")) |
| 90 | + |
| 91 | + (let ((cider-preferred-build-tool "invalid choice")) |
| 92 | + (expect (cider-project-type) :to-equal "build2")) |
| 93 | + |
| 94 | + (let ((cider-preferred-build-tool "build3")) |
| 95 | + (expect (cider-project-type) :to-equal "build2")))) |
| 96 | + |
| 97 | + (describe "when there are no choices available" |
| 98 | + (it "returns the value of `cider-jack-in-default'" |
| 99 | + (spy-on 'cider--identify-buildtools-present |
| 100 | + :and-return-value '()) |
| 101 | + (expect (cider-project-type) :to-equal cider-jack-in-default)))) |
38 | 102 |
|
| 103 | +;;; cider-jack-in tests |
39 | 104 |
|
40 | 105 | (describe "cider-inject-jack-in-dependencies" |
41 | 106 | :var (cider-jack-in-dependencies cider-jack-in-nrepl-middlewares cider-jack-in-lein-plugins cider-jack-in-dependencies-exclusions) |
|
174 | 239 | (expect (cider-add-clojure-dependencies-maybe nil) |
175 | 240 | :to-equal '(("Hello, I love you" "won't you tell me your name")))))) |
176 | 241 |
|
177 | | -(describe "cider-project-type" |
178 | | - (describe "when there is a single project" |
179 | | - (it "returns that type" |
180 | | - (spy-on 'cider--identify-buildtools-present |
181 | | - :and-return-value '(lein)) |
182 | | - (expect (cider-project-type) :to-equal 'lein))) |
183 | | - |
184 | | - (describe "when there are multiple possible project types" |
185 | | - (before-all |
186 | | - (spy-on 'cider--identify-buildtools-present |
187 | | - :and-return-value '("build1" "build2")) |
188 | | - ;; user choice build2 |
189 | | - (spy-on 'completing-read :and-return-value "build2")) |
190 | | - |
191 | | - (it "returns the choice entered by user" |
192 | | - (expect (cider-project-type) :to-equal "build2")) |
193 | 242 |
|
194 | | - (it "respects the value of `cider-preferred-build-tool'" |
195 | | - (let ((cider-preferred-build-tool "build1")) |
196 | | - (expect (cider-project-type) :to-equal "build1")) |
197 | | - |
198 | | - (let ((cider-preferred-build-tool "invalid choice")) |
199 | | - (expect (cider-project-type) :to-equal "build2")) |
200 | | - |
201 | | - (let ((cider-preferred-build-tool "build3")) |
202 | | - (expect (cider-project-type) :to-equal "build2")))) |
203 | | - |
204 | | - (describe "when there are no choices available" |
205 | | - (it "returns the value of `cider-jack-in-default'" |
206 | | - (spy-on 'cider--identify-buildtools-present |
207 | | - :and-return-value '()) |
208 | | - (expect (cider-project-type) :to-equal cider-jack-in-default)))) |
209 | 243 |
|
210 | 244 | (describe "cider-normalize-cljs-init-options" |
211 | 245 | (describe "from options" |
212 | 246 | (it "leaves keywords alone" |
213 | | - (expect (cider-normalize-cljs-init-options ":dev") :to-equal ":dev")) |
| 247 | + (expect (cider-normalize-cljs-init-options ":dev") :to-equal ":dev")) |
214 | 248 | (it "leaves maps alone" |
215 | | - (expect (cider-normalize-cljs-init-options "{:a 1 :b 2}") :to-equal "{:a 1 :b 2}")) |
| 249 | + (expect (cider-normalize-cljs-init-options "{:a 1 :b 2}") :to-equal "{:a 1 :b 2}")) |
216 | 250 | (it "leaves s-exprs alone" |
217 | | - (expect (cider-normalize-cljs-init-options "(hashmap :a 1 :b 2)") :to-equal "(hashmap :a 1 :b 2)")) |
| 251 | + (expect (cider-normalize-cljs-init-options "(hashmap :a 1 :b 2)") :to-equal "(hashmap :a 1 :b 2)")) |
218 | 252 | (it "leaves vectors alone" |
219 | | - (expect (cider-normalize-cljs-init-options "[1 2 3]") :to-equal "[1 2 3]")) |
220 | | - (it "prepends colon to plain names" |
221 | | - (expect (cider-normalize-cljs-init-options "dev") :to-equal ":dev")))) |
222 | | - |
223 | | -(describe "cider-figwheel-main-init-form" |
224 | | - ;; whitespace checks sprinkled amongst other tests |
225 | | - (describe "from options" |
226 | | - (it "leaves keywords alone" |
227 | | - (let ((cider-figwheel-main-default-options ":dev ")) |
228 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :dev))"))) |
229 | | - (it "leaves maps alone" |
230 | | - (let ((cider-figwheel-main-default-options " {:a 1 :b 2}")) |
231 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start {:a 1 :b 2}))"))) |
232 | | - (it "leaves s-exprs alone" |
233 | | - (let ((cider-figwheel-main-default-options " (hashmap :a 1 :b 2)")) |
234 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start (hashmap :a 1 :b 2)))"))) |
235 | | - (it "prepends colon to plain names" |
236 | | - (let ((cider-figwheel-main-default-options " dev")) |
237 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :dev))")))) |
238 | | - |
239 | | - (describe "from minibuffer" |
240 | | - (before-each |
241 | | - ;; not necessary as of this writing, but it can't hurt |
242 | | - (setq-local cider-figwheel-main-default-options nil)) |
243 | | - (it "leaves keywords alone" |
244 | | - (spy-on 'read-from-minibuffer :and-return-value " :prod ") |
245 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :prod))")) |
246 | | - (it "leaves maps alone" |
247 | | - (spy-on 'read-from-minibuffer :and-return-value " {:c 3 :d 4}") |
248 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start {:c 3 :d 4}))")) |
249 | | - (it "leaves s-exprs alone" |
250 | | - (spy-on 'read-from-minibuffer :and-return-value "(keyword \"dev\") ") |
251 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start (keyword \"dev\")))")) |
| 253 | + (expect (cider-normalize-cljs-init-options "[1 2 3]") :to-equal "[1 2 3]")) |
252 | 254 | (it "prepends colon to plain names" |
253 | | - (spy-on 'read-from-minibuffer :and-return-value "prod ") |
254 | | - (expect (cider-figwheel-main-init-form) :to-equal "(do (require 'figwheel.main) (figwheel.main/start :prod))")))) |
| 255 | + (expect (cider-normalize-cljs-init-options "dev") :to-equal ":dev")))) |
255 | 256 |
|
256 | 257 | (provide 'cider-tests) |
257 | 258 |
|
|
0 commit comments