|
1 | 1 | (ns cljfmt.config-test |
2 | 2 | (:require [cljfmt.config :as config] |
3 | | - [clojure.test :refer [deftest is]])) |
| 3 | + [clojure.test :refer [deftest is testing]] |
| 4 | + [clojure.java.io :as io])) |
4 | 5 |
|
5 | 6 | (deftest test-convert-legacy-keys |
6 | 7 | (is (= {:indents {'foo [[:inner 0]]}} |
7 | 8 | (config/convert-legacy-keys {:indents {'foo [[:inner 0]]}}))) |
8 | 9 | (is (= {:extra-indents {'foo [[:inner 0]]}} |
9 | 10 | (config/convert-legacy-keys {:legacy/merge-indents? true |
10 | 11 | :indents {'foo [[:inner 0]]}})))) |
| 12 | + |
| 13 | +(deftest test-load-config-extra-configs |
| 14 | + (testing ":extra-configs allows you to import :extra-indents" |
| 15 | + (is (= (config/load-config (io/resource "config_test/empty-cljfmt.edn")) |
| 16 | + (-> (config/load-config (io/resource "config_test/cljfmt.edn")) |
| 17 | + (dissoc :extra-configs) |
| 18 | + (assoc :extra-indents {}))) |
| 19 | + (str "should only differ by `:extra-indents` (via :extra-configs)." |
| 20 | + " All other keys are ignored.")) |
| 21 | + (is (= '{;; exists only in base config `test_resources/cljfmt.edn` |
| 22 | + com.unrelated/a [[:inner 0]] |
| 23 | + com.foo/a [[:inner 0]], |
| 24 | + ;; exists only in `test_resources/extra1-cljfmt.edn` |
| 25 | + com.foo/b [[:inner 1]], |
| 26 | + ;; overwritten in `test_resources/extra2-cljfmt.edn` |
| 27 | + com.foo/c [[:inner 2]], |
| 28 | + com.foo/d [[:inner 2]], |
| 29 | + ;; exists only in `test_resources/extra2-cljfmt.edn` |
| 30 | + com.foo/e [[:inner 2]]} |
| 31 | + (:extra-indents (config/load-config (io/resource "config_test/cljfmt.edn")))) |
| 32 | + (str "should respect :extra-configs in order (later is higher-prio)," |
| 33 | + " with base highest prio.")))) |
0 commit comments