Skip to content

Commit 7199d27

Browse files
authored
Merge pull request #358 from areina/fix-auto-ns-for-cljs-test
Require test framework in cljs files too
2 parents 7941d90 + 3d77132 commit 7199d27

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,13 @@ 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]"
198-
"The require form to use when clojure.test and cljs.test is in use in a cljc file."
203+
"The require form to use when clojure.test is in use in a clj file."
199204
:group 'cljr
200205
:type 'string)
201206

@@ -978,7 +983,7 @@ If CLJS? is T we insert in the cljs part of the ns declaration."
978983
(mapconcat 'identity (append (butlast ns-chunks) (list src-ns)) "."))))
979984

980985
(defun cljr--cljs-file-p (&optional buf)
981-
"Is BUF, or the current buffer, visiting a cljc file?"
986+
"Is BUF, or the current buffer, visiting a cljs file?"
982987
(s-equals-p (file-name-extension (buffer-file-name (or buf (current-buffer))))
983988
"cljs"))
984989

@@ -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)