@@ -113,6 +113,98 @@ line 3 foo`;
113113 } ) ;
114114 } ) ;
115115
116+ describe ( "case insensitive match strategy" , ( ) => {
117+ it ( "should find multiple occurrences with different cases" , ( ) => {
118+ const content = "const Foo = 'FOO';" ;
119+ const search = "foo" ;
120+ const matches = findSearchMatches ( content , search ) ;
121+
122+ expect ( matches ) . toHaveLength ( 2 ) ;
123+ expect ( matches [ 0 ] ) . toEqual ( {
124+ startIndex : 6 ,
125+ endIndex : 9 ,
126+ strategyName : "caseInsensitiveMatch" ,
127+ } ) ;
128+ expect ( matches [ 1 ] ) . toEqual ( {
129+ startIndex : 13 ,
130+ endIndex : 16 ,
131+ strategyName : "caseInsensitiveMatch" ,
132+ } ) ;
133+ } ) ;
134+
135+ it ( "should handle mixed case patterns" , ( ) => {
136+ const content = "const MyVariable = 'value';" ;
137+ const search = "mYvArIaBlE" ;
138+ const matches = findSearchMatches ( content , search ) ;
139+
140+ expect ( matches ) . toHaveLength ( 1 ) ;
141+ expect ( matches [ 0 ] ) . toEqual ( {
142+ startIndex : 6 ,
143+ endIndex : 16 ,
144+ strategyName : "caseInsensitiveMatch" ,
145+ } ) ;
146+ } ) ;
147+
148+ it ( "should find multiple matches with varying cases" , ( ) => {
149+ const content = "Hello world, HELLO universe, HeLLo there" ;
150+ const search = "hello" ;
151+ const matches = findSearchMatches ( content , search ) ;
152+
153+ expect ( matches ) . toHaveLength ( 3 ) ;
154+ expect ( matches [ 0 ] ) . toEqual ( {
155+ startIndex : 0 ,
156+ endIndex : 5 ,
157+ strategyName : "caseInsensitiveMatch" ,
158+ } ) ;
159+ expect ( matches [ 1 ] ) . toEqual ( {
160+ startIndex : 13 ,
161+ endIndex : 18 ,
162+ strategyName : "caseInsensitiveMatch" ,
163+ } ) ;
164+ expect ( matches [ 2 ] ) . toEqual ( {
165+ startIndex : 29 ,
166+ endIndex : 34 ,
167+ strategyName : "caseInsensitiveMatch" ,
168+ } ) ;
169+ } ) ;
170+
171+ it ( "should handle multi-line content with case differences" , ( ) => {
172+ const content = `function Test() {
173+ return TRUE;
174+ }` ;
175+ const search = "test" ;
176+ const matches = findSearchMatches ( content , search ) ;
177+
178+ expect ( matches ) . toHaveLength ( 1 ) ;
179+ expect ( matches [ 0 ] ) . toEqual ( {
180+ startIndex : 9 ,
181+ endIndex : 13 ,
182+ strategyName : "caseInsensitiveMatch" ,
183+ } ) ;
184+ } ) ;
185+
186+ it ( "should preserve original content length in match" , ( ) => {
187+ const content = "const VARIABLE = 'value';" ;
188+ const search = "variable" ;
189+ const matches = findSearchMatches ( content , search ) ;
190+
191+ expect ( matches ) . toHaveLength ( 1 ) ;
192+ expect ( matches [ 0 ] . endIndex - matches [ 0 ] . startIndex ) . toBe ( 8 ) ;
193+ expect ( content . slice ( matches [ 0 ] . startIndex , matches [ 0 ] . endIndex ) ) . toBe (
194+ "VARIABLE" ,
195+ ) ;
196+ } ) ;
197+
198+ it ( "should not match when exact and trimmed strategies succeed" , ( ) => {
199+ const content = "const foo = 'bar';" ;
200+ const search = "foo" ;
201+ const matches = findSearchMatches ( content , search ) ;
202+
203+ expect ( matches ) . toHaveLength ( 1 ) ;
204+ expect ( matches [ 0 ] . strategyName ) . toBe ( "exactMatch" ) ;
205+ } ) ;
206+ } ) ;
207+
116208 describe ( "whitespace ignored match strategy" , ( ) => {
117209 it ( "should find matches ignoring internal whitespace" , ( ) => {
118210 const content = "const foo = bar;" ;
0 commit comments