@@ -48,22 +48,26 @@ import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKe
48
48
import { platform } from 'vs/base/common/platform' ;
49
49
import { arch } from 'vs/base/common/process' ;
50
50
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
51
+ import { DisposableStore , toDisposable } from 'vs/base/common/lifecycle' ;
51
52
52
53
suite ( 'ExtensionsWorkbenchServiceTest' , ( ) => {
53
54
54
55
let instantiationService : TestInstantiationService ;
55
56
let testObject : IExtensionsWorkbenchService ;
57
+ const suiteDisposables = new DisposableStore ( ) ;
58
+ let testDisposables : DisposableStore = new DisposableStore ( ) ;
56
59
57
60
let installEvent : Emitter < InstallExtensionEvent > ,
58
61
didInstallEvent : Emitter < readonly InstallExtensionResult [ ] > ,
59
62
uninstallEvent : Emitter < UninstallExtensionEvent > ,
60
63
didUninstallEvent : Emitter < DidUninstallExtensionEvent > ;
61
64
62
65
suiteSetup ( ( ) => {
63
- installEvent = new Emitter < InstallExtensionEvent > ( ) ;
64
- didInstallEvent = new Emitter < readonly InstallExtensionResult [ ] > ( ) ;
65
- uninstallEvent = new Emitter < UninstallExtensionEvent > ( ) ;
66
- didUninstallEvent = new Emitter < DidUninstallExtensionEvent > ( ) ;
66
+ suiteDisposables . add ( toDisposable ( ( ) => sinon . restore ( ) ) ) ;
67
+ installEvent = suiteDisposables . add ( new Emitter < InstallExtensionEvent > ( ) ) ;
68
+ didInstallEvent = suiteDisposables . add ( new Emitter < readonly InstallExtensionResult [ ] > ( ) ) ;
69
+ uninstallEvent = suiteDisposables . add ( new Emitter < UninstallExtensionEvent > ( ) ) ;
70
+ didUninstallEvent = suiteDisposables . add ( new Emitter < DidUninstallExtensionEvent > ( ) ) ;
67
71
68
72
instantiationService = new TestInstantiationService ( ) ;
69
73
instantiationService . stub ( ITelemetryService , NullTelemetryService ) ;
@@ -126,7 +130,10 @@ suite('ExtensionsWorkbenchServiceTest', () => {
126
130
} ) ;
127
131
} ) ;
128
132
133
+ suiteTeardown ( ( ) => suiteDisposables . dispose ( ) ) ;
134
+
129
135
setup ( async ( ) => {
136
+ testDisposables = new DisposableStore ( ) ;
130
137
instantiationService . stubPromise ( IExtensionManagementService , 'getInstalled' , [ ] ) ;
131
138
instantiationService . stub ( IExtensionGalleryService , 'isEnabled' , true ) ;
132
139
instantiationService . stubPromise ( IExtensionGalleryService , 'query' , aPage ( ) ) ;
@@ -135,9 +142,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
135
142
( < TestExtensionEnablementService > instantiationService . get ( IWorkbenchExtensionEnablementService ) ) . reset ( ) ;
136
143
} ) ;
137
144
138
- teardown ( ( ) => {
139
- ( < ExtensionsWorkbenchService > testObject ) . dispose ( ) ;
140
- } ) ;
145
+ teardown ( ( ) => testDisposables . dispose ( ) ) ;
141
146
142
147
test ( 'test gallery extension' , async ( ) => {
143
148
const expected = aGalleryExtension ( 'expectedName' , {
@@ -1412,7 +1417,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
1412
1417
} ) ;
1413
1418
1414
1419
async function aWorkbenchService ( ) : Promise < ExtensionsWorkbenchService > {
1415
- const workbenchService : ExtensionsWorkbenchService = instantiationService . createInstance ( ExtensionsWorkbenchService ) ;
1420
+ const workbenchService : ExtensionsWorkbenchService = testDisposables . add ( instantiationService . createInstance ( ExtensionsWorkbenchService ) ) ;
1416
1421
await workbenchService . queryLocal ( ) ;
1417
1422
return workbenchService ;
1418
1423
}
0 commit comments