33
44import * as sinon from 'sinon' ;
55import * as typeMoq from 'typemoq' ;
6- import { GlobalEnvironmentVariableCollection , workspace } from 'vscode' ;
6+ import { Disposable , GlobalEnvironmentVariableCollection , workspace , WorkspaceFolder } from 'vscode' ;
7+ import { DidChangeEnvironmentVariablesEventArgs } from '../../api' ;
78import { EnvVarManager } from '../../features/execution/envVariableManager' ;
89import { TerminalEnvVarInjector } from '../../features/terminal/terminalEnvVarInjector' ;
910
@@ -18,8 +19,7 @@ suite('TerminalEnvVarInjector Basic Tests', () => {
1819 let envVarManager : typeMoq . IMock < EnvVarManager > ;
1920 let injector : TerminalEnvVarInjector ;
2021 let mockScopedCollection : MockScopedCollection ;
21- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22- let workspaceFoldersStub : any ;
22+ let workspaceFoldersStub : WorkspaceFolder [ ] ;
2323
2424 setup ( ( ) => {
2525 envVarCollection = typeMoq . Mock . ofType < GlobalEnvironmentVariableCollection > ( ) ;
@@ -40,19 +40,25 @@ suite('TerminalEnvVarInjector Basic Tests', () => {
4040 } ;
4141
4242 // Setup environment variable collection to return scoped collection
43- envVarCollection . setup ( ( x ) => x . getScoped ( typeMoq . It . isAny ( ) ) ) . returns ( ( ) => mockScopedCollection as any ) ;
43+ envVarCollection . setup ( ( x ) => x . getScoped ( typeMoq . It . isAny ( ) ) ) . returns ( ( ) => mockScopedCollection as never ) ;
4444 envVarCollection . setup ( ( x ) => x . clear ( ) ) . returns ( ( ) => { } ) ;
4545
4646 // Setup minimal mocks for event subscriptions
4747 envVarManager
4848 . setup ( ( m ) => m . onDidChangeEnvironmentVariables )
49- . returns (
50- ( ) =>
49+ . returns ( ( ) => {
50+ // Return a mock Event function that returns a Disposable when called
51+ const mockEvent = ( _listener : ( e : DidChangeEnvironmentVariablesEventArgs ) => void ) =>
5152 ( {
5253 dispose : ( ) => { } ,
53- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54- } as any ) ,
55- ) ;
54+ } as Disposable ) ;
55+ return mockEvent ;
56+ } ) ;
57+
58+ // Mock workspace.onDidChangeConfiguration to return a Disposable
59+ sinon . stub ( workspace , 'onDidChangeConfiguration' ) . returns ( {
60+ dispose : ( ) => { } ,
61+ } as Disposable ) ;
5662 } ) ;
5763
5864 teardown ( ( ) => {
@@ -85,12 +91,21 @@ suite('TerminalEnvVarInjector Basic Tests', () => {
8591 envVarManager . reset ( ) ;
8692 envVarManager
8793 . setup ( ( m ) => m . onDidChangeEnvironmentVariables )
88- . returns ( ( _handler ) => {
94+ . returns ( ( ) => {
8995 eventHandlerRegistered = true ;
90- // eslint-disable-next-line @typescript-eslint/no-explicit-any
91- return { dispose : ( ) => { } } as any ;
96+ // Return a mock Event function that returns a Disposable when called
97+ const mockEvent = ( _listener : ( e : DidChangeEnvironmentVariablesEventArgs ) => void ) =>
98+ ( {
99+ dispose : ( ) => { } ,
100+ } as Disposable ) ;
101+ return mockEvent ;
92102 } ) ;
93103
104+ // Mock workspace.onDidChangeConfiguration to return a Disposable
105+ sinon . stub ( workspace , 'onDidChangeConfiguration' ) . returns ( {
106+ dispose : ( ) => { } ,
107+ } as Disposable ) ;
108+
94109 // Act
95110 injector = new TerminalEnvVarInjector ( envVarCollection . object , envVarManager . object ) ;
96111
0 commit comments