11import * as path from "path"
2+ import { describe , it , expect , beforeEach , afterEach , vi } from "vitest"
23
34// Mock dependencies
4- jest . mock ( "fs" , ( ) => ( {
5- existsSync : jest . fn ( ) ,
6- readFileSync : jest . fn ( ) ,
5+ vi . mock ( "fs" , ( ) => ( {
6+ existsSync : vi . fn ( ) ,
7+ readFileSync : vi . fn ( ) ,
78} ) )
89
9- const mockOs = {
10- platform : jest . fn ( ) ,
11- }
12-
13- jest . mock ( "os" , ( ) => mockOs )
10+ vi . mock ( "os" , ( ) => ( {
11+ platform : vi . fn ( ) ,
12+ } ) )
1413
15- jest . mock ( "@roo-code/cloud" , ( ) => ( {
14+ vi . mock ( "@roo-code/cloud" , ( ) => ( {
1615 CloudService : {
17- hasInstance : jest . fn ( ) ,
16+ hasInstance : vi . fn ( ) ,
1817 instance : {
19- hasActiveSession : jest . fn ( ) ,
20- getOrganizationId : jest . fn ( ) ,
18+ hasActiveSession : vi . fn ( ) ,
19+ getOrganizationId : vi . fn ( ) ,
2120 } ,
2221 } ,
2322} ) )
2423
25- jest . mock ( "vscode" , ( ) => ( {
24+ vi . mock ( "vscode" , ( ) => ( {
2625 workspace : {
27- getConfiguration : jest . fn ( ) ,
26+ getConfiguration : vi . fn ( ) ,
2827 } ,
2928 ConfigurationTarget : {
3029 Global : 1 ,
3130 } ,
3231} ) )
3332
34- jest . mock ( "../../../shared/package" , ( ) => ( {
33+ vi . mock ( "../../../shared/package" , ( ) => ( {
3534 Package : {
3635 publisher : "roo-code" ,
3736 name : "roo-cline" ,
@@ -47,9 +46,10 @@ import * as vscode from "vscode"
4746import { MdmService } from "../MdmService"
4847import { CloudService } from "@roo-code/cloud"
4948
50- const mockFs = fs as jest . Mocked < typeof fs >
51- const mockCloudService = CloudService as jest . Mocked < typeof CloudService >
52- const mockVscode = vscode as jest . Mocked < typeof vscode >
49+ const mockFs = fs as any
50+ const mockOs = os as any
51+ const mockCloudService = CloudService as any
52+ const mockVscode = vscode as any
5353
5454describe ( "MdmService" , ( ) => {
5555 let originalPlatform : string
@@ -66,13 +66,13 @@ describe("MdmService", () => {
6666
6767 // Setup VSCode mocks
6868 const mockConfig = {
69- get : jest . fn ( ) . mockReturnValue ( false ) ,
70- update : jest . fn ( ) . mockResolvedValue ( undefined ) ,
69+ get : vi . fn ( ) . mockReturnValue ( false ) ,
70+ update : vi . fn ( ) . mockResolvedValue ( undefined ) ,
7171 }
72- ; ( mockVscode . workspace . getConfiguration as jest . Mock ) . mockReturnValue ( mockConfig )
72+ mockVscode . workspace . getConfiguration . mockReturnValue ( mockConfig )
7373
7474 // Reset mocks
75- jest . clearAllMocks ( )
75+ vi . clearAllMocks ( )
7676 } )
7777
7878 afterEach ( ( ) => {
@@ -235,7 +235,7 @@ describe("MdmService", () => {
235235 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
236236
237237 mockCloudService . hasInstance . mockReturnValue ( true )
238- ; ( mockCloudService . instance . hasActiveSession as jest . Mock ) . mockReturnValue ( true )
238+ mockCloudService . instance . hasActiveSession . mockReturnValue ( true )
239239
240240 const service = await MdmService . createInstance ( )
241241 const compliance = service . isCompliant ( )
@@ -268,8 +268,8 @@ describe("MdmService", () => {
268268 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
269269
270270 mockCloudService . hasInstance . mockReturnValue ( true )
271- ; ( mockCloudService . instance . hasActiveSession as jest . Mock ) . mockReturnValue ( true )
272- ; ( mockCloudService . instance . getOrganizationId as jest . Mock ) . mockReturnValue ( "different-org-456" )
271+ mockCloudService . instance . hasActiveSession . mockReturnValue ( true )
272+ mockCloudService . instance . getOrganizationId . mockReturnValue ( "different-org-456" )
273273
274274 const service = await MdmService . createInstance ( )
275275 const compliance = service . isCompliant ( )
@@ -289,8 +289,8 @@ describe("MdmService", () => {
289289 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
290290
291291 mockCloudService . hasInstance . mockReturnValue ( true )
292- ; ( mockCloudService . instance . hasActiveSession as jest . Mock ) . mockReturnValue ( true )
293- ; ( mockCloudService . instance . getOrganizationId as jest . Mock ) . mockReturnValue ( "correct-org-123" )
292+ mockCloudService . instance . hasActiveSession . mockReturnValue ( true )
293+ mockCloudService . instance . getOrganizationId . mockReturnValue ( "correct-org-123" )
294294
295295 const service = await MdmService . createInstance ( )
296296 const compliance = service . isCompliant ( )
@@ -310,10 +310,10 @@ describe("MdmService", () => {
310310 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
311311
312312 const mockVsCodeConfig = {
313- get : jest . fn ( ) . mockReturnValue ( false ) , // rooCodeCloudEnabled is false
314- update : jest . fn ( ) . mockResolvedValue ( undefined ) ,
313+ get : vi . fn ( ) . mockReturnValue ( false ) , // rooCodeCloudEnabled is false
314+ update : vi . fn ( ) . mockResolvedValue ( undefined ) ,
315315 }
316- ; ( mockVscode . workspace . getConfiguration as jest . Mock ) . mockReturnValue ( mockVsCodeConfig )
316+ mockVscode . workspace . getConfiguration . mockReturnValue ( mockVsCodeConfig )
317317
318318 await MdmService . createInstance ( )
319319
@@ -332,10 +332,10 @@ describe("MdmService", () => {
332332 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
333333
334334 const mockVsCodeConfig = {
335- get : jest . fn ( ) . mockReturnValue ( true ) , // rooCodeCloudEnabled is already true
336- update : jest . fn ( ) . mockResolvedValue ( undefined ) ,
335+ get : vi . fn ( ) . mockReturnValue ( true ) , // rooCodeCloudEnabled is already true
336+ update : vi . fn ( ) . mockResolvedValue ( undefined ) ,
337337 }
338- ; ( mockVscode . workspace . getConfiguration as jest . Mock ) . mockReturnValue ( mockVsCodeConfig )
338+ mockVscode . workspace . getConfiguration . mockReturnValue ( mockVsCodeConfig )
339339
340340 await MdmService . createInstance ( )
341341
@@ -352,10 +352,10 @@ describe("MdmService", () => {
352352 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
353353
354354 const mockVsCodeConfig = {
355- get : jest . fn ( ) . mockReturnValue ( false ) ,
356- update : jest . fn ( ) . mockResolvedValue ( undefined ) ,
355+ get : vi . fn ( ) . mockReturnValue ( false ) ,
356+ update : vi . fn ( ) . mockResolvedValue ( undefined ) ,
357357 }
358- ; ( mockVscode . workspace . getConfiguration as jest . Mock ) . mockReturnValue ( mockVsCodeConfig )
358+ mockVscode . workspace . getConfiguration . mockReturnValue ( mockVsCodeConfig )
359359
360360 await MdmService . createInstance ( )
361361
@@ -366,10 +366,10 @@ describe("MdmService", () => {
366366 mockFs . existsSync . mockReturnValue ( false )
367367
368368 const mockVsCodeConfig = {
369- get : jest . fn ( ) . mockReturnValue ( false ) ,
370- update : jest . fn ( ) . mockResolvedValue ( undefined ) ,
369+ get : vi . fn ( ) . mockReturnValue ( false ) ,
370+ update : vi . fn ( ) . mockResolvedValue ( undefined ) ,
371371 }
372- ; ( mockVscode . workspace . getConfiguration as jest . Mock ) . mockReturnValue ( mockVsCodeConfig )
372+ mockVscode . workspace . getConfiguration . mockReturnValue ( mockVsCodeConfig )
373373
374374 await MdmService . createInstance ( )
375375
@@ -385,10 +385,10 @@ describe("MdmService", () => {
385385 mockFs . readFileSync . mockReturnValue ( JSON . stringify ( mockConfig ) )
386386
387387 const mockVsCodeConfig = {
388- get : jest . fn ( ) . mockReturnValue ( false ) ,
389- update : jest . fn ( ) . mockRejectedValue ( new Error ( "Configuration update failed" ) ) ,
388+ get : vi . fn ( ) . mockReturnValue ( false ) ,
389+ update : vi . fn ( ) . mockRejectedValue ( new Error ( "Configuration update failed" ) ) ,
390390 }
391- ; ( mockVscode . workspace . getConfiguration as jest . Mock ) . mockReturnValue ( mockVsCodeConfig )
391+ mockVscode . workspace . getConfiguration . mockReturnValue ( mockVsCodeConfig )
392392
393393 // Should not throw
394394 await expect ( MdmService . createInstance ( ) ) . resolves . toBeInstanceOf ( MdmService )
0 commit comments