From ffa78ec086a4a2484265d56ffbede504495304b8 Mon Sep 17 00:00:00 2001 From: yuhan0 Date: Thu, 22 Apr 2021 05:11:20 +0800 Subject: [PATCH] Update tests --- ...jure-mode-refactor-rename-ns-alias-test.el | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/test/clojure-mode-refactor-rename-ns-alias-test.el b/test/clojure-mode-refactor-rename-ns-alias-test.el index d5d99cb9..37fe90c6 100644 --- a/test/clojure-mode-refactor-rename-ns-alias-test.el +++ b/test/clojure-mode-refactor-rename-ns-alias-test.el @@ -127,18 +127,48 @@ (m*/operator 1 (math.-/subtract 2 3))" (clojure--rename-ns-alias-internal "math.*" "m*")) - (it "should offer completions" + (when-refactoring-it "should replace aliases in region" + "(str/join []) + +(s/with-gen #(string/includes? % \"gen/nope\") + #(gen/fmap (fn [[s1 s2]] (str s1 \"hello\" s2)) + (gen/tuple (gen/string-alphanumeric) (gen/string-alphanumeric)))) + +(gen/different-library)" + "(string/join []) + +(s/with-gen #(string/includes? % \"gen/nope\") + #(s.gen/fmap (fn [[s1 s2]] (str s1 \"hello\" s2)) + (s.gen/tuple (s.gen/string-alphanumeric) (s.gen/string-alphanumeric)))) + +(gen/different-library)" + + (clojure--rename-ns-alias-usages "str" "string" (point-min) 13) + (clojure--rename-ns-alias-usages "gen" "s.gen" (point-min) (- (point-max) 23))) + + (it "should offer completions for ns forms" (expect - (clojure-collect-ns-aliases - "(ns test.ns + (with-clojure-buffer + "(ns test.ns (:require [my.math.subtraction :as math.-] [my.math.multiplication :as math.*] [clojure.spec.alpha :as s] ;; [clojure.spec.alpha2 :as s2] [symbols :as abc123.-$#.%*+!@])) -(math.*/operator 1 (math.-/subtract 2 3))") - :to-equal '("abc123.-$#.%*+!@" "s" "math.*" "math.-")))) +(math.*/operator 1 (math.-/subtract 2 3))" + (clojure--collect-ns-aliases (point-min) (point-max) 'ns-form)) + :to-equal '("math.-" "math.*" "s" "abc123.-$#.%*+!@"))) + + (it "should offer completions for usages in region" + (expect + (with-clojure-buffer + "(s/with-gen #(string/includes? % \"hello\") + #(gen/fmap (fn [[s1 s2]] (str s1 \"hello\" s2)) + (gen/tuple (gen/string-alphanumeric) (gen/string-alphanumeric))))" + (clojure--collect-ns-aliases (point-min) (point-max) nil)) + :to-equal '("s" "string" "gen")))) + (provide 'clojure-mode-refactor-rename-ns-alias-test)