@@ -28,6 +28,9 @@ vi.mock("vscode", () => ({
2828 fs : {
2929 stat : vi . fn ( ) ,
3030 } ,
31+ getConfiguration : vi . fn ( ) . mockReturnValue ( {
32+ get : vi . fn ( ) . mockImplementation ( ( key , defaultValue ) => defaultValue ) ,
33+ } ) ,
3134 } ,
3235 window : {
3336 createTextEditorDecorationType : vi . fn ( ) ,
@@ -45,6 +48,12 @@ vi.mock("vscode", () => ({
4548 languages : {
4649 getDiagnostics : vi . fn ( ( ) => [ ] ) ,
4750 } ,
51+ DiagnosticSeverity : {
52+ Error : 0 ,
53+ Warning : 1 ,
54+ Information : 2 ,
55+ Hint : 3 ,
56+ } ,
4857 WorkspaceEdit : vi . fn ( ) . mockImplementation ( ( ) => ( {
4958 replace : vi . fn ( ) ,
5059 delete : vi . fn ( ) ,
@@ -337,18 +346,18 @@ describe("DiffViewProvider", () => {
337346 return 1000 // 1 second delay
338347 }
339348 return defaultValue
340- } )
349+ } ) ,
341350 } )
342-
351+
343352 // Save original implementation
344353 const originalGetConfiguration = vscode . workspace . getConfiguration
345-
354+
346355 // Replace with our mock
347356 Object . defineProperty ( vscode . workspace , "getConfiguration" , {
348357 value : mockGetConfiguration ,
349- configurable : true
358+ configurable : true ,
350359 } )
351-
360+
352361 // Mock setTimeout to track if it was called
353362 const originalSetTimeout = global . setTimeout
354363 const mockSetTimeout = vi . fn ( ) . mockImplementation ( ( callback , delay ) => {
@@ -357,7 +366,7 @@ describe("DiffViewProvider", () => {
357366 return 1 // Return a timeout ID
358367 } )
359368 global . setTimeout = mockSetTimeout as any
360-
369+
361370 // Setup the diffViewProvider for testing
362371 ; ( diffViewProvider as any ) . relPath = "test.txt"
363372 ; ( diffViewProvider as any ) . newContent = "Test content"
@@ -371,31 +380,31 @@ describe("DiffViewProvider", () => {
371380 isDirty : false ,
372381 save : vi . fn ( ) . mockResolvedValue ( undefined ) ,
373382 }
374-
383+
375384 // Mock getDiagnostics to track when it's called
376385 const mockGetDiagnostics = vi . fn ( ) . mockReturnValue ( [ ] )
377386 const originalGetDiagnostics = vscode . languages . getDiagnostics
378387 vscode . languages . getDiagnostics = mockGetDiagnostics
379-
388+
380389 // Mock showTextDocument
381390 vi . mocked ( vscode . window . showTextDocument ) . mockResolvedValue ( { } as any )
382-
391+
383392 // Execute saveChanges
384393 await diffViewProvider . saveChanges ( )
385-
394+
386395 // Verify that getConfiguration was called with "roo-cline"
387396 expect ( mockGetConfiguration ) . toHaveBeenCalledWith ( "roo-cline" )
388-
397+
389398 // Verify that setTimeout was called with the correct delay
390399 expect ( mockSetTimeout ) . toHaveBeenCalledWith ( expect . any ( Function ) , 1000 )
391-
400+
392401 // Verify that getDiagnostics was called after the delay
393402 expect ( mockGetDiagnostics ) . toHaveBeenCalled ( )
394-
403+
395404 // Restore original implementations
396405 Object . defineProperty ( vscode . workspace , "getConfiguration" , {
397406 value : originalGetConfiguration ,
398- configurable : true
407+ configurable : true ,
399408 } )
400409 global . setTimeout = originalSetTimeout
401410 vscode . languages . getDiagnostics = originalGetDiagnostics
0 commit comments