11import { CxInstaller } from "../main/osinstaller/CxInstaller" ;
22import { anyString , mock , instance , when , verify } from "ts-mockito" ;
3- import { HttpClient } from "../main/client/HttpClient " ;
3+ import { AstClient } from "../main/client/AstClient " ;
44
5- const clientMock = mock ( HttpClient ) ;
6- const clientMockInstance = instance ( clientMock ) ;
5+ // Mock AstClient and set up an instance from it
6+ const astClientMock = mock ( AstClient ) ;
7+ const astClientInstance = instance ( astClientMock ) ;
78
8- const cxInstallerLinux = new CxInstaller ( "linux" , clientMockInstance ) ;
9- const cxInstallerMac = new CxInstaller ( "darwin" , clientMockInstance ) ;
10- const cxInstallerWindows = new CxInstaller ( "win32" , clientMockInstance ) ;
9+ // Create CxInstaller instances with the mocked AstClient
10+ const cxInstallerLinux = new CxInstaller ( "linux" , astClientInstance ) ;
11+ const cxInstallerMac = new CxInstaller ( "darwin" , astClientInstance ) ;
12+ const cxInstallerWindows = new CxInstaller ( "win32" , astClientInstance ) ;
1113
1214describe ( "CxInstaller cases" , ( ) => {
1315 it ( 'CxInstaller getDownloadURL Linux Successful case' , async ( ) => {
@@ -48,16 +50,12 @@ describe("CxInstaller getExecutablePath cases", () => {
4850
4951describe ( "CxInstaller checkExecutableExists cases" , ( ) => {
5052 beforeAll ( async ( ) => {
51- // Set up mock behavior
52- when ( clientMock . downloadFile ( anyString ( ) , anyString ( ) ) ) . thenResolve ( ) ;
53-
54- // Trigger the download
53+ when ( astClientMock . downloadFile ( anyString ( ) , anyString ( ) ) ) . thenResolve ( ) ; // Set up mock behavior here
5554 await cxInstallerWindows . downloadIfNotInstalledCLI ( ) ;
5655 } ) ;
5756
5857 it ( 'CxInstaller checkExecutableExists Windows Successful case' , ( ) => {
59- // Verify if downloadFile was called with the expected arguments
60- verify ( clientMock . downloadFile ( anyString ( ) , anyString ( ) ) ) . called ( ) ;
58+ verify ( astClientMock . downloadFile ( anyString ( ) , anyString ( ) ) ) . called ( ) ;
6159 } ) ;
6260} ) ;
6361
@@ -72,4 +70,4 @@ function getArchitecture(platform: string): string {
7270 } ;
7371
7472 return archMap [ process . arch ] || 'x64' ;
75- }
73+ }
0 commit comments