-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(ns refactor-nrepl.ns.libspec-whitelist-test | ||
(:require | ||
[clojure.test :refer [are deftest is testing]] | ||
[refactor-nrepl.ns.libspec-whitelist :as sut] | ||
[refactor-nrepl.ns.prune-dependencies :as prune-dependencies])) | ||
|
||
(deftest libspec-whitelist | ||
(testing "Takes into account refactor-nrepls own config, and .clj-kondo/config files alike, | ||
merging their results" | ||
(is (= [;; From refactor-nrepl's default config: | ||
"^cljsjs" | ||
;; from our .clj-kondo file - symbols become quoted patterns: | ||
"^\\Qsample.unused.namespace\\E$" | ||
;; from our .clj-kondo file - strings have 'regex' semantics so are kept as-is: | ||
"more.unused.namespaces*"] | ||
|
||
(sut/libspec-whitelist))) | ||
|
||
(is (every? string? (sut/libspec-whitelist)) | ||
"Items coming from different sources all have the same class, | ||
ensuring they will be treated homogeneously by refactor-nrepl") | ||
|
||
(testing "`libspec-should-never-be-pruned?` is integrated with clj-kondo logic, | ||
effecively parsing its config into well-formed regexes" | ||
(are [input expected] (= expected | ||
(prune-dependencies/libspec-should-never-be-pruned? {:ns input})) | ||
'sample.unused.namespace true | ||
'Asample.unused.namespace false | ||
'sample.unused.namespaceB false | ||
'more.unused.namespaces true | ||
'more.unused.namespacessss true | ||
'more.unused.namespac false)))) |