@@ -15,6 +15,8 @@ import {
15
15
ILanguageServerCompatibilityService ,
16
16
ILanguageServerFolderService
17
17
} from '../../client/activation/types' ;
18
+ import { LSNotSupportedDiagnosticServiceId } from '../../client/application/diagnostics/checks/lsNotSupported' ;
19
+ import { IDiagnosticsService } from '../../client/application/diagnostics/types' ;
18
20
import {
19
21
IApplicationShell , ICommandManager ,
20
22
IWorkspaceService
@@ -36,6 +38,7 @@ suite('Activation - ActivationService', () => {
36
38
let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
37
39
let platformService : TypeMoq . IMock < IPlatformService > ;
38
40
let lanagueServerSupportedService : TypeMoq . IMock < ILanguageServerCompatibilityService > ;
41
+ let lsNotSupportedDiagnosticService : TypeMoq . IMock < IDiagnosticsService > ;
39
42
setup ( ( ) => {
40
43
serviceContainer = TypeMoq . Mock . ofType < IServiceContainer > ( ) ;
41
44
appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
@@ -50,6 +53,7 @@ suite('Activation - ActivationService', () => {
50
53
version : new SemVer ( '1.2.3' )
51
54
} ;
52
55
lanagueServerSupportedService = TypeMoq . Mock . ofType < ILanguageServerCompatibilityService > ( ) ;
56
+ lsNotSupportedDiagnosticService = TypeMoq . Mock . ofType < IDiagnosticsService > ( ) ;
53
57
workspaceService . setup ( w => w . hasWorkspaceFolders ) . returns ( ( ) => false ) ;
54
58
workspaceService . setup ( w => w . workspaceFolders ) . returns ( ( ) => [ ] ) ;
55
59
configService . setup ( c => c . getSettings ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => pythonSettings . object ) ;
@@ -64,6 +68,7 @@ suite('Activation - ActivationService', () => {
64
68
serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( ICommandManager ) ) ) . returns ( ( ) => cmdManager . object ) ;
65
69
serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IPlatformService ) ) ) . returns ( ( ) => platformService . object ) ;
66
70
serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( ILanguageServerFolderService ) ) ) . returns ( ( ) => langFolderServiceMock . object ) ;
71
+ serviceContainer . setup ( s => s . get ( TypeMoq . It . isValue ( IDiagnosticsService ) , TypeMoq . It . isValue ( LSNotSupportedDiagnosticServiceId ) ) ) . returns ( ( ) => lsNotSupportedDiagnosticService . object ) ;
67
72
} ) ;
68
73
69
74
async function testActivation ( activationService : IExtensionActivationService , activator : TypeMoq . IMock < IExtensionActivator > , lsSupported : boolean = true ) {
@@ -74,6 +79,14 @@ suite('Activation - ActivationService', () => {
74
79
if ( lsSupported && ! jediIsEnabled ) {
75
80
activatorName = ExtensionActivators . DotNet ;
76
81
}
82
+ let diagnostics ;
83
+ if ( ! lsSupported && ! jediIsEnabled ) {
84
+ diagnostics = [ TypeMoq . It . isAny ( ) ] ;
85
+ } else {
86
+ diagnostics = [ ] ;
87
+ }
88
+ lsNotSupportedDiagnosticService . setup ( l => l . diagnose ( ) ) . returns ( ( ) => diagnostics ) ;
89
+ lsNotSupportedDiagnosticService . setup ( l => l . handle ( TypeMoq . It . isValue ( diagnostics ) ) ) . returns ( ( ) => Promise . resolve ( ) ) ;
77
90
serviceContainer
78
91
. setup ( c => c . get ( TypeMoq . It . isValue ( IExtensionActivator ) , TypeMoq . It . isValue ( activatorName ) ) )
79
92
. returns ( ( ) => activator . object )
@@ -89,15 +102,15 @@ suite('Activation - ActivationService', () => {
89
102
lanagueServerSupportedService . setup ( ls => ls . isSupported ( ) ) . returns ( ( ) => Promise . resolve ( true ) ) ;
90
103
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabled ) ;
91
104
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
92
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
105
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
93
106
94
107
await testActivation ( activationService , activator , true ) ;
95
108
} ) ;
96
109
test ( 'LS is not supported' , async ( ) => {
97
110
lanagueServerSupportedService . setup ( ls => ls . isSupported ( ) ) . returns ( ( ) => Promise . resolve ( false ) ) ;
98
111
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabled ) ;
99
112
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
100
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
113
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
101
114
102
115
await testActivation ( activationService , activator , false ) ;
103
116
} ) ;
@@ -106,15 +119,15 @@ suite('Activation - ActivationService', () => {
106
119
lanagueServerSupportedService . setup ( ls => ls . isSupported ( ) ) . returns ( ( ) => Promise . resolve ( true ) ) ;
107
120
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabled ) ;
108
121
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
109
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
122
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
110
123
111
124
await testActivation ( activationService , activator ) ;
112
125
} ) ;
113
126
test ( 'Activatory must be deactivated' , async ( ) => {
114
127
lanagueServerSupportedService . setup ( ls => ls . isSupported ( ) ) . returns ( ( ) => Promise . resolve ( true ) ) ;
115
128
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabled ) ;
116
129
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
117
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
130
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
118
131
119
132
await testActivation ( activationService , activator ) ;
120
133
@@ -137,7 +150,7 @@ suite('Activation - ActivationService', () => {
137
150
138
151
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabledValueInSetting ) ;
139
152
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
140
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
153
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
141
154
142
155
workspaceService . verifyAll ( ) ;
143
156
await testActivation ( activationService , activator ) ;
@@ -172,7 +185,7 @@ suite('Activation - ActivationService', () => {
172
185
173
186
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabledValueInSetting ) ;
174
187
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
175
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
188
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
176
189
177
190
workspaceService . verifyAll ( ) ;
178
191
await testActivation ( activationService , activator ) ;
@@ -206,7 +219,7 @@ suite('Activation - ActivationService', () => {
206
219
207
220
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabled ) ;
208
221
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
209
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
222
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
210
223
211
224
workspaceService . verifyAll ( ) ;
212
225
await testActivation ( activationService , activator ) ;
@@ -239,7 +252,7 @@ suite('Activation - ActivationService', () => {
239
252
240
253
pythonSettings . setup ( p => p . jediEnabled ) . returns ( ( ) => jediIsEnabled ) ;
241
254
const activator = TypeMoq . Mock . ofType < IExtensionActivator > ( ) ;
242
- const activationService = new ExtensionActivationService ( serviceContainer . object , lanagueServerSupportedService . object ) ;
255
+ const activationService = new ExtensionActivationService ( serviceContainer . object ) ;
243
256
244
257
workspaceService . verifyAll ( ) ;
245
258
await testActivation ( activationService , activator ) ;
0 commit comments