Skip to content

Commit c211a27

Browse files
authoredMay 2, 2021
Rename ns aliases in selected region (#590)
1 parent a3c442a commit c211a27

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed
 

‎clojure-mode-refactor-rename-ns-alias-test.el

+35-5
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,48 @@
127127
(m*/operator 1 (math.-/subtract 2 3))"
128128
(clojure--rename-ns-alias-internal "math.*" "m*"))
129129

130-
(it "should offer completions"
130+
(when-refactoring-it "should replace aliases in region"
131+
"(str/join [])
132+
133+
(s/with-gen #(string/includes? % \"gen/nope\")
134+
#(gen/fmap (fn [[s1 s2]] (str s1 \"hello\" s2))
135+
(gen/tuple (gen/string-alphanumeric) (gen/string-alphanumeric))))
136+
137+
(gen/different-library)"
138+
"(string/join [])
139+
140+
(s/with-gen #(string/includes? % \"gen/nope\")
141+
#(s.gen/fmap (fn [[s1 s2]] (str s1 \"hello\" s2))
142+
(s.gen/tuple (s.gen/string-alphanumeric) (s.gen/string-alphanumeric))))
143+
144+
(gen/different-library)"
145+
146+
(clojure--rename-ns-alias-usages "str" "string" (point-min) 13)
147+
(clojure--rename-ns-alias-usages "gen" "s.gen" (point-min) (- (point-max) 23)))
148+
149+
(it "should offer completions for ns forms"
131150
(expect
132-
(clojure-collect-ns-aliases
133-
"(ns test.ns
151+
(with-clojure-buffer
152+
"(ns test.ns
134153
(:require [my.math.subtraction :as math.-]
135154
[my.math.multiplication :as math.*]
136155
[clojure.spec.alpha :as s]
137156
;; [clojure.spec.alpha2 :as s2]
138157
[symbols :as abc123.-$#.%*+!@]))
139158
140-
(math.*/operator 1 (math.-/subtract 2 3))")
141-
:to-equal '("abc123.-$#.%*+!@" "s" "math.*" "math.-"))))
159+
(math.*/operator 1 (math.-/subtract 2 3))"
160+
(clojure--collect-ns-aliases (point-min) (point-max) 'ns-form))
161+
:to-equal '("math.-" "math.*" "s" "abc123.-$#.%*+!@")))
162+
163+
(it "should offer completions for usages in region"
164+
(expect
165+
(with-clojure-buffer
166+
"(s/with-gen #(string/includes? % \"hello\")
167+
#(gen/fmap (fn [[s1 s2]] (str s1 \"hello\" s2))
168+
(gen/tuple (gen/string-alphanumeric) (gen/string-alphanumeric))))"
169+
(clojure--collect-ns-aliases (point-min) (point-max) nil))
170+
:to-equal '("s" "string" "gen"))))
171+
142172

143173
(provide 'clojure-mode-refactor-rename-ns-alias-test)
144174

0 commit comments

Comments
 (0)
Please sign in to comment.