3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { should , expect } from 'chai ' ;
6
+ import { describe , test , expect , beforeEach } from '@jest/globals ' ;
7
7
import { getNullChannel } from '../../../test/unitTests/fakes' ;
8
8
import { CsharpLoggerObserver } from '../../../src/shared/observers/csharpLoggerObserver' ;
9
9
import { PlatformInformation } from '../../../src/shared/platform' ;
10
10
import * as Event from '../../../src/omnisharp/loggingEvents' ;
11
11
import { PackageError } from '../../../src/packageManager/packageError' ;
12
12
import { Package } from '../../../src/packageManager/package' ;
13
13
14
- suite ( 'CsharpLoggerObserver' , ( ) => {
15
- suiteSetup ( ( ) => should ( ) ) ;
16
-
14
+ describe ( 'CsharpLoggerObserver' , ( ) => {
17
15
let logOutput = '' ;
18
16
const observer = new CsharpLoggerObserver ( {
19
17
...getNullChannel ( ) ,
@@ -29,30 +27,30 @@ suite('CsharpLoggerObserver', () => {
29
27
architectures : [ ] ,
30
28
} ;
31
29
32
- setup ( ( ) => {
30
+ beforeEach ( ( ) => {
33
31
logOutput = '' ;
34
32
} ) ;
35
33
36
34
test ( 'PlatformInfo: Logs contain the Platform and Architecture' , ( ) => {
37
35
const event = new Event . LogPlatformInfo ( new PlatformInformation ( 'linux' , 'MyArchitecture' ) ) ;
38
36
observer . post ( event ) ;
39
- expect ( logOutput ) . to . contain ( 'linux' ) ;
40
- expect ( logOutput ) . to . contain ( 'MyArchitecture' ) ;
37
+ expect ( logOutput ) . toContain ( 'linux' ) ;
38
+ expect ( logOutput ) . toContain ( 'MyArchitecture' ) ;
41
39
} ) ;
42
40
43
- suite ( 'InstallationFailure' , ( ) => {
41
+ describe ( 'InstallationFailure' , ( ) => {
44
42
test ( 'Stage and Error is logged if not a PackageError' , ( ) => {
45
43
const event = new Event . InstallationFailure ( 'someStage' , new Error ( 'someError' ) ) ;
46
44
observer . post ( event ) ;
47
- expect ( logOutput ) . to . contain ( event . stage ) ;
48
- expect ( logOutput ) . to . contain ( event . error . toString ( ) ) ;
45
+ expect ( logOutput ) . toContain ( event . stage ) ;
46
+ expect ( logOutput ) . toContain ( event . error . toString ( ) ) ;
49
47
} ) ;
50
48
51
49
test ( 'Stage and Error is logged if a PackageError without inner error' , ( ) => {
52
50
const event = new Event . InstallationFailure ( 'someStage' , new PackageError ( 'someError' , pkg , undefined ) ) ;
53
51
observer . post ( event ) ;
54
- expect ( logOutput ) . to . contain ( event . stage ) ;
55
- expect ( logOutput ) . to . contain ( event . error . message ) ;
52
+ expect ( logOutput ) . toContain ( event . stage ) ;
53
+ expect ( logOutput ) . toContain ( event . error . message ) ;
56
54
} ) ;
57
55
58
56
test ( 'Stage and Inner error is logged if a PackageError without inner error' , ( ) => {
@@ -61,12 +59,12 @@ suite('CsharpLoggerObserver', () => {
61
59
new PackageError ( 'someError' , pkg , new Error ( 'innerError' ) )
62
60
) ;
63
61
observer . post ( event ) ;
64
- expect ( logOutput ) . to . contain ( event . stage ) ;
65
- expect ( logOutput ) . to . contain ( event . error . innerError . toString ( ) ) ;
62
+ expect ( logOutput ) . toContain ( event . stage ) ;
63
+ expect ( logOutput ) . toContain ( event . error . innerError . toString ( ) ) ;
66
64
} ) ;
67
65
} ) ;
68
66
69
- suite ( 'Download' , ( ) => {
67
+ describe ( 'Download' , ( ) => {
70
68
const packageName = 'somePackage' ;
71
69
[
72
70
{
@@ -155,7 +153,7 @@ suite('CsharpLoggerObserver', () => {
155
153
} ) ;
156
154
157
155
element . events . forEach ( ( message : Event . BaseEvent ) => observer . post ( message ) ) ;
158
- expect ( logOutput ) . to . be . equal ( element . expected ) ;
156
+ expect ( logOutput ) . toEqual ( element . expected ) ;
159
157
} ) ;
160
158
} ) ;
161
159
} ) ;
@@ -172,66 +170,66 @@ suite('CsharpLoggerObserver', () => {
172
170
] . forEach ( ( element ) =>
173
171
test ( `${ element . message . constructor . name } is shown` , ( ) => {
174
172
observer . post ( element . message ) ;
175
- expect ( logOutput ) . to . contain ( element . expected ) ;
173
+ expect ( logOutput ) . toContain ( element . expected ) ;
176
174
} )
177
175
) ;
178
176
179
177
test ( `ActivationFailure: Some message is logged` , ( ) => {
180
178
const event = new Event . ActivationFailure ( ) ;
181
179
observer . post ( event ) ;
182
- expect ( logOutput ) . to . not . be . empty ;
180
+ expect ( logOutput ) . toBeTruthy ( ) ;
183
181
} ) ;
184
182
185
183
test ( `ProjectJsonDeprecatedWarning: Some message is logged` , ( ) => {
186
184
const event = new Event . ProjectJsonDeprecatedWarning ( ) ;
187
185
observer . post ( event ) ;
188
- expect ( logOutput ) . to . not . be . empty ;
186
+ expect ( logOutput ) . toBeTruthy ( ) ;
189
187
} ) ;
190
188
191
189
test ( `InstallationSuccess: Some message is logged` , ( ) => {
192
190
const event = new Event . InstallationSuccess ( ) ;
193
191
observer . post ( event ) ;
194
- expect ( logOutput ) . to . not . be . empty ;
192
+ expect ( logOutput ) . toBeTruthy ( ) ;
195
193
} ) ;
196
194
197
195
test ( `InstallationProgress: Progress message is logged` , ( ) => {
198
196
const event = new Event . InstallationStart ( 'somPackage' ) ;
199
197
observer . post ( event ) ;
200
- expect ( logOutput ) . to . contain ( event . packageDescription ) ;
198
+ expect ( logOutput ) . toContain ( event . packageDescription ) ;
201
199
} ) ;
202
200
203
201
test ( 'PackageInstallation: Package name is logged' , ( ) => {
204
202
const event = new Event . PackageInstallation ( 'somePackage' ) ;
205
203
observer . post ( event ) ;
206
- expect ( logOutput ) . to . contain ( event . packageInfo ) ;
204
+ expect ( logOutput ) . toContain ( event . packageInfo ) ;
207
205
} ) ;
208
206
209
207
test ( 'DownloadFallBack: The fallbackurl is logged' , ( ) => {
210
208
const event = new Event . DownloadFallBack ( 'somrurl' ) ;
211
209
observer . post ( event ) ;
212
- expect ( logOutput ) . to . contain ( event . fallbackUrl ) ;
210
+ expect ( logOutput ) . toContain ( event . fallbackUrl ) ;
213
211
} ) ;
214
212
215
213
test ( `${ Event . IntegrityCheckFailure . name } : Package Description is logged when we are retrying` , ( ) => {
216
214
const description = 'someDescription' ;
217
215
const url = 'someUrl' ;
218
216
const event = new Event . IntegrityCheckFailure ( description , url , true ) ;
219
217
observer . post ( event ) ;
220
- expect ( logOutput ) . to . contain ( description ) ;
218
+ expect ( logOutput ) . toContain ( description ) ;
221
219
} ) ;
222
220
223
221
test ( `${ Event . IntegrityCheckFailure . name } : Package Description and url are logged when we are not retrying` , ( ) => {
224
222
const description = 'someDescription' ;
225
223
const url = 'someUrl' ;
226
224
const event = new Event . IntegrityCheckFailure ( description , url , false ) ;
227
225
observer . post ( event ) ;
228
- expect ( logOutput ) . to . contain ( description ) ;
229
- expect ( logOutput ) . to . contain ( url ) ;
226
+ expect ( logOutput ) . toContain ( description ) ;
227
+ expect ( logOutput ) . toContain ( url ) ;
230
228
} ) ;
231
229
232
230
test ( `${ Event . IntegrityCheckSuccess . name } : Some message is logged` , ( ) => {
233
231
const event = new Event . IntegrityCheckSuccess ( ) ;
234
232
observer . post ( event ) ;
235
- expect ( logOutput ) . to . not . be . empty ;
233
+ expect ( logOutput ) . toBeTruthy ( ) ;
236
234
} ) ;
237
235
} ) ;
0 commit comments