@@ -26,8 +26,10 @@ describe("normalizeConfig", () => {
2626 } ,
2727 } ;
2828 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 ) ;
3133 } ) ;
3234
3335 it ( "classifies dotted keys as exact" , async ( ) => {
@@ -90,8 +92,12 @@ describe("normalizeConfig", () => {
9092 } ,
9193 } ;
9294 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+ ] ) ;
95101 } ) ;
96102
97103 it ( "applies include/exclude defaults" , async ( ) => {
@@ -130,6 +136,18 @@ describe("normalizeConfig", () => {
130136 expect ( result . fileFilter ( "other/file.ts" ) ) . toBe ( false ) ;
131137 } ) ;
132138
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+
133151 it ( "uses basicMatcher by default" , async ( ) => {
134152 const result = await normalizeConfig ( { } ) ;
135153 expect ( result . matcher ) . toBe ( basicMatcher ) ;
@@ -146,7 +164,7 @@ describe("normalizeConfig", () => {
146164 it ( "throws if strategy name ends with '!'" , async ( ) => {
147165 const config : Config < any > = {
148166 byStrategy : {
149- "merge!" : [ "foo" ] ,
167+ "merge!! " : [ "foo" ] ,
150168 } ,
151169 } ;
152170 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", () => {
168186 } ,
169187 } ;
170188 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 ) ;
172190 } ) ;
173191
174192 it ( "marks important from rules tree key with '!'" , async ( ) => {
@@ -180,7 +198,7 @@ describe("normalizeConfig", () => {
180198 } ,
181199 } ;
182200 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 ) ;
184202 } ) ;
185203
186204 it ( "throws on invalid bracket form with dot" , async ( ) => {
@@ -221,7 +239,9 @@ describe("normalizeConfig", () => {
221239 } ,
222240 } ;
223241 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+ ] ) ;
225245 } ) ;
226246
227247 it ( "push appends to same key" , async ( ) => {
@@ -232,6 +252,9 @@ describe("normalizeConfig", () => {
232252 } ,
233253 } ;
234254 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+ ] ) ;
236259 } ) ;
237260} ) ;
0 commit comments