@@ -74,4 +74,65 @@ describe('androidStudio', () => {
7474 } ".`,
7575 ) ;
7676 } ) ;
77+
78+ it ( 'detects Android Studio in the fallback Windows installation path' , async ( ) => {
79+ // Make CLI think Android Studio was not found
80+ environmentInfo . IDEs [ 'Android Studio' ] = 'Not Found' ;
81+ // Force platform to win32 for the test
82+ // TODO: use cleaner jest.replaceProperty in jest 29+
83+ const originalPlatform = process . platform ;
84+ Object . defineProperty ( process , 'platform' , {
85+ value : 'win32' ,
86+ writable : true ,
87+ configurable : true ,
88+ } ) ;
89+
90+ // First WMIC (primary) returns empty, second (fallback) returns version
91+ ( execa as unknown as jest . Mock )
92+ . mockResolvedValueOnce ( { stdout : '' } )
93+ . mockResolvedValueOnce ( { stdout : '4.2.1.0' } ) ;
94+
95+ const diagnostics = await androidStudio . getDiagnostics ( environmentInfo ) ;
96+
97+ expect ( diagnostics . needsToBeFixed ) . toBe ( false ) ;
98+ expect ( diagnostics . version ) . toBe ( '4.2.1.0' ) ;
99+
100+ // Restore original platform
101+ // TODO: use cleaner mockRestore in jest 29+
102+ Object . defineProperty ( process , 'platform' , {
103+ value : originalPlatform ,
104+ writable : true ,
105+ configurable : true ,
106+ } ) ;
107+ } ) ;
108+
109+ it ( 'detects when Android Studio is also not in fallback installation path' , async ( ) => {
110+ // Make CLI think Android Studio was not found
111+ environmentInfo . IDEs [ 'Android Studio' ] = 'Not Found' ;
112+ // Force the platform to win32 for the test
113+ // TODO: use cleaner jest.replaceProperty in jest 29+
114+ const originalPlatform = process . platform ;
115+ Object . defineProperty ( process , 'platform' , {
116+ value : 'win32' ,
117+ writable : true ,
118+ configurable : true ,
119+ } ) ;
120+
121+ // First WMIC (primary) returns empty, second (fallback) returns version
122+ ( execa as unknown as jest . Mock )
123+ . mockResolvedValueOnce ( { stdout : '' } )
124+ . mockResolvedValueOnce ( { stdout : '' } ) ;
125+
126+ const diagnostics = await androidStudio . getDiagnostics ( environmentInfo ) ;
127+
128+ expect ( diagnostics . needsToBeFixed ) . toBe ( true ) ;
129+
130+ // Restore original platform
131+ // TODO: use cleaner mockRestore in jest 29+
132+ Object . defineProperty ( process , 'platform' , {
133+ value : originalPlatform ,
134+ writable : true ,
135+ configurable : true ,
136+ } ) ;
137+ } ) ;
77138} ) ;
0 commit comments