3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
+ import * as vscode from 'vscode' ;
7
+ import { describe , test , expect , beforeEach , jest } from '@jest/globals' ;
6
8
import { OmniSharpMonoResolver } from '../../../src/omnisharp/omniSharpMonoResolver' ;
7
9
8
- import { expect } from 'chai' ;
9
10
import { join } from 'path' ;
11
+ import { getWorkspaceConfiguration } from '../../../test/unitTests/fakes' ;
10
12
11
- suite ( `${ OmniSharpMonoResolver . name } ` , ( ) => {
13
+ describe ( `${ OmniSharpMonoResolver . name } ` , ( ) => {
12
14
let getMonoCalled : boolean ;
13
15
14
16
const monoPath = 'monoPath' ;
@@ -22,41 +24,32 @@ suite(`${OmniSharpMonoResolver.name}`, () => {
22
24
return Promise . resolve ( version ) ;
23
25
} ;
24
26
25
- setup ( ( ) => {
27
+ beforeEach ( ( ) => {
26
28
getMonoCalled = false ;
29
+ jest . spyOn ( vscode . workspace , 'getConfiguration' ) . mockReturnValue ( getWorkspaceConfiguration ( ) ) ;
30
+ vscode . workspace . getConfiguration ( ) . update ( 'omnisharp.monoPath' , monoPath ) ;
27
31
} ) ;
28
32
29
33
test ( `it returns the path and version if the version is greater than or equal to ${ requiredMonoVersion } ` , async ( ) => {
30
34
const monoResolver = new OmniSharpMonoResolver ( getMono ( higherMonoVersion ) ) ;
31
- const monoInfo = await monoResolver . getHostExecutableInfo ( /*{
32
- ...options,
33
- omnisharpOptions: { ...options.omnisharpOptions, monoPath: monoPath },
34
- }*/ ) ;
35
+ const monoInfo = await monoResolver . getHostExecutableInfo ( ) ;
35
36
36
- expect ( monoInfo . version ) . to . be . equal ( higherMonoVersion ) ;
37
- expect ( monoInfo . path ) . to . be . equal ( monoPath ) ;
37
+ expect ( monoInfo . version ) . toEqual ( higherMonoVersion ) ;
38
+ expect ( monoInfo . path ) . toEqual ( monoPath ) ;
38
39
} ) ;
39
40
40
41
test ( `it throws exception if version is less than ${ requiredMonoVersion } ` , async ( ) => {
41
42
const monoResolver = new OmniSharpMonoResolver ( getMono ( lowerMonoVersion ) ) ;
42
43
43
- await expect (
44
- monoResolver . getHostExecutableInfo ( /*{
45
- ...options,
46
- omnisharpOptions: { ...options.omnisharpOptions, monoPath: monoPath },
47
- }*/ )
48
- ) . to . be . rejected ;
44
+ await expect ( monoResolver . getHostExecutableInfo ( ) ) . rejects . toThrow ( ) ;
49
45
} ) ;
50
46
51
47
test ( 'sets the environment with the monoPath' , async ( ) => {
52
48
const monoResolver = new OmniSharpMonoResolver ( getMono ( requiredMonoVersion ) ) ;
53
- const monoInfo = await monoResolver . getHostExecutableInfo ( /*{
54
- ...options,
55
- omnisharpOptions: { ...options.omnisharpOptions, monoPath: monoPath },
56
- }*/ ) ;
57
-
58
- expect ( getMonoCalled ) . to . be . equal ( true ) ;
59
- expect ( monoInfo . env [ 'PATH' ] ) . to . contain ( join ( monoPath , 'bin' ) ) ;
60
- expect ( monoInfo . env [ 'MONO_GAC_PREFIX' ] ) . to . be . equal ( monoPath ) ;
49
+ const monoInfo = await monoResolver . getHostExecutableInfo ( ) ;
50
+
51
+ expect ( getMonoCalled ) . toEqual ( true ) ;
52
+ expect ( monoInfo . env [ 'PATH' ] ) . toContain ( join ( monoPath , 'bin' ) ) ;
53
+ expect ( monoInfo . env [ 'MONO_GAC_PREFIX' ] ) . toEqual ( monoPath ) ;
61
54
} ) ;
62
55
} ) ;
0 commit comments