@@ -26,6 +26,15 @@ import {
2626 benchifyCanFixLanguage ,
2727} from '../tools/batch-str-replace'
2828
29+ import type { Logger } from '@codebuff/types/logger'
30+
31+ const logger : Logger = {
32+ debug : ( ) => { } ,
33+ info : ( ) => { } ,
34+ warn : ( ) => { } ,
35+ error : ( ) => { } ,
36+ }
37+
2938describe ( 'processStrReplace' , ( ) => {
3039 it ( 'should replace exact string matches' , async ( ) => {
3140 const initialContent = 'const x = 1;\nconst y = 2;\n'
@@ -36,6 +45,7 @@ describe('processStrReplace', () => {
3645 path : 'test.ts' ,
3746 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
3847 initialContentPromise : Promise . resolve ( initialContent ) ,
48+ logger,
3949 } )
4050
4151 expect ( result ) . not . toBeNull ( )
@@ -56,6 +66,7 @@ describe('processStrReplace', () => {
5666 path : 'test.ts' ,
5767 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
5868 initialContentPromise : Promise . resolve ( initialContent ) ,
69+ logger,
5970 } )
6071
6172 expect ( result ) . not . toBeNull ( )
@@ -75,6 +86,7 @@ describe('processStrReplace', () => {
7586 path : 'test.ts' ,
7687 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
7788 initialContentPromise : Promise . resolve ( initialContent ) ,
89+ logger,
7890 } )
7991
8092 expect ( result ) . not . toBeNull ( )
@@ -93,6 +105,7 @@ describe('processStrReplace', () => {
93105 path : 'test.ts' ,
94106 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
95107 initialContentPromise : Promise . resolve ( initialContent ) ,
108+ logger,
96109 } )
97110
98111 expect ( result ) . not . toBeNull ( )
@@ -107,6 +120,7 @@ describe('processStrReplace', () => {
107120 path : 'test.ts' ,
108121 replacements : [ { old : 'old' , new : 'new' , allowMultiple : false } ] ,
109122 initialContentPromise : Promise . resolve ( null ) ,
123+ logger,
110124 } )
111125
112126 expect ( result ) . not . toBeNull ( )
@@ -121,6 +135,7 @@ describe('processStrReplace', () => {
121135 path : 'test.ts' ,
122136 replacements : [ { old : '' , new : 'new' , allowMultiple : false } ] ,
123137 initialContentPromise : Promise . resolve ( 'content' ) ,
138+ logger,
124139 } )
125140
126141 expect ( result ) . not . toBeNull ( )
@@ -139,6 +154,7 @@ describe('processStrReplace', () => {
139154 path : 'test.ts' ,
140155 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
141156 initialContentPromise : Promise . resolve ( initialContent ) ,
157+ logger,
142158 } )
143159
144160 expect ( result ) . not . toBeNull ( )
@@ -159,6 +175,7 @@ describe('processStrReplace', () => {
159175 path : 'test.ts' ,
160176 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
161177 initialContentPromise : Promise . resolve ( initialContent ) ,
178+ logger,
162179 } )
163180
164181 expect ( result ) . not . toBeNull ( )
@@ -177,6 +194,7 @@ describe('processStrReplace', () => {
177194 path : 'test.ts' ,
178195 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
179196 initialContentPromise : Promise . resolve ( initialContent ) ,
197+ logger,
180198 } )
181199
182200 expect ( result ) . not . toBeNull ( )
@@ -198,6 +216,7 @@ describe('processStrReplace', () => {
198216 path : 'test.ts' ,
199217 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
200218 initialContentPromise : Promise . resolve ( initialContent ) ,
219+ logger,
201220 } )
202221
203222 expect ( result ) . not . toBeNull ( )
@@ -221,6 +240,7 @@ describe('processStrReplace', () => {
221240 path : 'test.ts' ,
222241 replacements,
223242 initialContentPromise : Promise . resolve ( initialContent ) ,
243+ logger,
224244 } )
225245
226246 expect ( result ) . not . toBeNull ( )
@@ -245,6 +265,7 @@ describe('processStrReplace', () => {
245265 path : 'test.ts' ,
246266 replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
247267 initialContentPromise : Promise . resolve ( initialContent ) ,
268+ logger,
248269 } )
249270
250271 expect ( result ) . not . toBeNull ( )
@@ -262,11 +283,12 @@ describe('processStrReplace', () => {
262283 const oldStr = 'const x'
263284 const newStr = 'let x'
264285
265- const result = await processStrReplace ( {
266- path : 'test.ts' ,
267- replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
268- initialContentPromise : Promise . resolve ( initialContent ) ,
269- } )
286+ const result = await processStrReplace ( {
287+ path : 'test.ts' ,
288+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
289+ initialContentPromise : Promise . resolve ( initialContent ) ,
290+ logger,
291+ } )
270292
271293 expect ( result ) . not . toBeNull ( )
272294 expect ( 'error' in result ) . toBe ( true )
@@ -285,6 +307,7 @@ describe('processStrReplace', () => {
285307 path : 'test.ts' ,
286308 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
287309 initialContentPromise : Promise . resolve ( initialContent ) ,
310+ logger,
288311 } )
289312
290313 expect ( result ) . not . toBeNull ( )
@@ -303,6 +326,7 @@ describe('processStrReplace', () => {
303326 path : 'test.ts' ,
304327 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
305328 initialContentPromise : Promise . resolve ( initialContent ) ,
329+ logger,
306330 } )
307331
308332 expect ( result ) . not . toBeNull ( )
@@ -324,6 +348,7 @@ describe('processStrReplace', () => {
324348 path : 'test.ts' ,
325349 replacements,
326350 initialContentPromise : Promise . resolve ( initialContent ) ,
351+ logger,
327352 } )
328353
329354 expect ( result ) . not . toBeNull ( )
@@ -355,6 +380,7 @@ function test3() {
355380 path : 'test.ts' ,
356381 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
357382 initialContentPromise : Promise . resolve ( initialContent ) ,
383+ logger,
358384 } )
359385
360386 expect ( result ) . not . toBeNull ( )
@@ -378,6 +404,7 @@ function test3() {
378404 path : 'test.ts' ,
379405 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
380406 initialContentPromise : Promise . resolve ( initialContent ) ,
407+ logger,
381408 } )
382409
383410 expect ( result ) . not . toBeNull ( )
@@ -401,6 +428,7 @@ function test3() {
401428 path : 'test.ts' ,
402429 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
403430 initialContentPromise : Promise . resolve ( initialContent ) ,
431+ logger,
404432 } )
405433
406434 expect ( result ) . not . toBeNull ( )
@@ -420,6 +448,7 @@ function test3() {
420448 path : 'test.ts' ,
421449 replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
422450 initialContentPromise : Promise . resolve ( initialContent ) ,
451+ logger,
423452 } )
424453
425454 expect ( result ) . not . toBeNull ( )
@@ -451,6 +480,7 @@ function test3() {
451480 path : 'test.ts' ,
452481 replacements,
453482 initialContentPromise : Promise . resolve ( initialContent ) ,
483+ logger,
454484 } )
455485
456486 expect ( 'content' in result ) . toBe ( true )
0 commit comments