Skip to content

Commit 08522e5

Browse files
committed
Convert remaining failing mocha tests to jest
1 parent 755350a commit 08522e5

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

omnisharptest/omnisharpUnitTests/omnisharp/omniSharpMonoResolver.test.ts renamed to omnisharptest/omnisharpJestTests/omnisharp/omniSharpMonoResolver.test.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import * as vscode from 'vscode';
7+
import { describe, test, expect, beforeEach, jest } from '@jest/globals';
68
import { OmniSharpMonoResolver } from '../../../src/omnisharp/omniSharpMonoResolver';
79

8-
import { expect } from 'chai';
910
import { join } from 'path';
11+
import { getWorkspaceConfiguration } from '../../../test/unitTests/fakes';
1012

11-
suite(`${OmniSharpMonoResolver.name}`, () => {
13+
describe(`${OmniSharpMonoResolver.name}`, () => {
1214
let getMonoCalled: boolean;
1315

1416
const monoPath = 'monoPath';
@@ -22,41 +24,32 @@ suite(`${OmniSharpMonoResolver.name}`, () => {
2224
return Promise.resolve(version);
2325
};
2426

25-
setup(() => {
27+
beforeEach(() => {
2628
getMonoCalled = false;
29+
jest.spyOn(vscode.workspace, 'getConfiguration').mockReturnValue(getWorkspaceConfiguration());
30+
vscode.workspace.getConfiguration().update('omnisharp.monoPath', monoPath);
2731
});
2832

2933
test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion}`, async () => {
3034
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();
3536

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);
3839
});
3940

4041
test(`it throws exception if version is less than ${requiredMonoVersion}`, async () => {
4142
const monoResolver = new OmniSharpMonoResolver(getMono(lowerMonoVersion));
4243

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();
4945
});
5046

5147
test('sets the environment with the monoPath', async () => {
5248
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);
6154
});
6255
});

0 commit comments

Comments
 (0)