@@ -26,8 +26,10 @@ describe("normalizeConfig", () => {
26
26
} ,
27
27
} ;
28
28
const result = await normalizeConfig ( config ) ;
29
- expect ( result . rules . exactFields . foo [ 0 ] . strategies ) . toEqual ( [ "replace" ] ) ;
30
- expect ( result . rules . exactFields . bar [ 0 ] . important ) . toBe ( true ) ;
29
+ expect ( result . rules . exactFields . foo [ 0 ] . strategies ) . toEqual ( [
30
+ { name : "replace" , important : false } ,
31
+ ] ) ;
32
+ expect ( result . rules . exactFields . bar [ 0 ] . strategies [ 0 ] . important ) . toBe ( true ) ;
31
33
} ) ;
32
34
33
35
it ( "classifies dotted keys as exact" , async ( ) => {
@@ -90,8 +92,12 @@ describe("normalizeConfig", () => {
90
92
} ,
91
93
} ;
92
94
const result = await normalizeConfig ( config ) ;
93
- expect ( result . rules . exact [ "user.name" ] [ 0 ] . strategies ) . toEqual ( [ "replace" ] ) ;
94
- expect ( result . rules . exact [ "user.profile.age" ] [ 0 ] . strategies ) . toEqual ( [ "merge" ] ) ;
95
+ expect ( result . rules . exact [ "user.name" ] [ 0 ] . strategies ) . toEqual ( [
96
+ { name : "replace" , important : false } ,
97
+ ] ) ;
98
+ expect ( result . rules . exact [ "user.profile.age" ] [ 0 ] . strategies ) . toEqual ( [
99
+ { name : "merge" , important : false } ,
100
+ ] ) ;
95
101
} ) ;
96
102
97
103
it ( "applies include/exclude defaults" , async ( ) => {
@@ -130,6 +136,18 @@ describe("normalizeConfig", () => {
130
136
expect ( result . fileFilter ( "other/file.ts" ) ) . toBe ( false ) ;
131
137
} ) ;
132
138
139
+ it ( "fileFilter includes allowed files and excludes others" , async ( ) => {
140
+ const result = await normalizeConfig ( {
141
+ include : [ "src/**/*.json" ] ,
142
+ exclude : [ "src/ignore/**" ] ,
143
+ } ) ;
144
+ expect ( result . fileFilter ( "src/index.ts" ) ) . toBe ( false ) ;
145
+ expect ( result . fileFilter ( "src/index.json" ) ) . toBe ( true ) ;
146
+ expect ( result . fileFilter ( "src/abc/index.json" ) ) . toBe ( true ) ;
147
+ expect ( result . fileFilter ( "src/ignore/file.ts" ) ) . toBe ( false ) ;
148
+ expect ( result . fileFilter ( "other/file.json" ) ) . toBe ( false ) ;
149
+ } ) ;
150
+
133
151
it ( "uses basicMatcher by default" , async ( ) => {
134
152
const result = await normalizeConfig ( { } ) ;
135
153
expect ( result . matcher ) . toBe ( basicMatcher ) ;
@@ -146,7 +164,7 @@ describe("normalizeConfig", () => {
146
164
it ( "throws if strategy name ends with '!'" , async ( ) => {
147
165
const config : Config < any > = {
148
166
byStrategy : {
149
- "merge!" : [ "foo" ] ,
167
+ "merge!! " : [ "foo" ] ,
150
168
} ,
151
169
} ;
152
170
await expect ( normalizeConfig ( config ) ) . rejects . toThrow ( / m u s t n o t e n d w i t h " ! " / ) ;
@@ -168,7 +186,7 @@ describe("normalizeConfig", () => {
168
186
} ,
169
187
} ;
170
188
const result = await normalizeConfig ( config ) ;
171
- expect ( result . rules . exactFields . foo [ 0 ] . important ) . toBe ( true ) ;
189
+ expect ( result . rules . exactFields . foo [ 0 ] . strategies [ 0 ] . important ) . toBe ( true ) ;
172
190
} ) ;
173
191
174
192
it ( "marks important from rules tree key with '!'" , async ( ) => {
@@ -180,7 +198,7 @@ describe("normalizeConfig", () => {
180
198
} ,
181
199
} ;
182
200
const result = await normalizeConfig ( config ) ;
183
- expect ( result . rules . exact [ "user.id" ] [ 0 ] . important ) . toBe ( true ) ;
201
+ expect ( result . rules . exact [ "user.id" ] [ 0 ] . strategies [ 0 ] . important ) . toBe ( true ) ;
184
202
} ) ;
185
203
186
204
it ( "throws on invalid bracket form with dot" , async ( ) => {
@@ -221,7 +239,9 @@ describe("normalizeConfig", () => {
221
239
} ,
222
240
} ;
223
241
const result = await normalizeConfig ( config ) ;
224
- expect ( result . rules . exact [ "root.child.leaf" ] [ 0 ] . strategies ) . toEqual ( [ "merge" ] ) ;
242
+ expect ( result . rules . exact [ "root.child.leaf" ] [ 0 ] . strategies ) . toEqual ( [
243
+ { name : "merge" , important : false } ,
244
+ ] ) ;
225
245
} ) ;
226
246
227
247
it ( "push appends to same key" , async ( ) => {
@@ -232,6 +252,9 @@ describe("normalizeConfig", () => {
232
252
} ,
233
253
} ;
234
254
const result = await normalizeConfig ( config ) ;
235
- expect ( result . rules . exactFields . dup . map ( r => r . strategies [ 0 ] ) ) . toEqual ( [ "merge" , "replace" ] ) ;
255
+ expect ( result . rules . exactFields . dup . map ( r => r . strategies [ 0 ] ) ) . toEqual ( [
256
+ { name : "merge" , important : false } ,
257
+ { name : "replace" , important : false } ,
258
+ ] ) ;
236
259
} ) ;
237
260
} ) ;
0 commit comments