Skip to content

Commit 680855c

Browse files
committed
Update cljr--add-test-declarations to work with cljs files
Insert a custom test declaration in cljs files
1 parent 36bfcb3 commit 680855c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [#301] (https://github.com/clojure-emacs/clj-refactor.el/issues/301) `ad` has gained a prefix to declare the symbol under the cursor.
77
- [#312](https://github.com/clojure-emacs/clj-refactor.el/issues/312) Allow `sut` alias to be customized.
88
- [#305](https://github.com/clojure-emacs/clj-refactor.el/issues/305) Don't call lookup-alias for non namespaced keywords at all when slash is typed. However trigger lookup alias with the leading :: stripped off the prefix if the keyword is namespaced.
9+
- Require a custom test framework for Clojurescript test files. By default it's `cljs.test` but it can be customized with `cljr-cljs-clojure-test-declaration`.
910

1011
### Changes
1112

clj-refactor.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ won't run if there is a broken namespace in the project."
194194
:group 'cljr
195195
:type 'string)
196196

197+
(defcustom cljr-cljs-clojure-test-declaration "[cljs.test :as t :include-macros true]"
198+
"The require form to use when cljs.test is in use in a cljs file."
199+
:group 'cljr
200+
:type 'string)
201+
197202
(defcustom cljr-clojure-test-declaration "[clojure.test :as t]"
198203
"The require form to use when clojure.test and cljs.test is in use in a cljc file."
199204
:group 'cljr
@@ -1007,6 +1012,8 @@ If CLJS? is T we insert in the cljs part of the ns declaration."
10071012
cljr-midje-test-declaration)
10081013
((cljr--project-depends-on-p "expectations")
10091014
cljr-expectations-test-declaration)
1015+
((cljr--cljs-file-p)
1016+
cljr-cljs-clojure-test-declaration)
10101017
((cljr--cljc-file-p)
10111018
cljr-cljc-clojure-test-declaration)
10121019
(t cljr-clojure-test-declaration))))

features/auto-ns.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,12 @@ Feature: Add namespace to blank .clj files
7474
#?(:clj [clojure.test :as t]
7575
:cljs [cljs.test :as t :include-macros true])))
7676
"""
77+
78+
Scenario: cljs file
79+
When I open file "tmp/test/cljr/core_test.cljs"
80+
Then I should see:
81+
"""
82+
(ns cljr.core-test
83+
(:require [cljr.core :as sut]
84+
[cljs.test :as t :include-macros true]))
85+
"""

0 commit comments

Comments
 (0)