Skip to content

Commit 559ecdf

Browse files
Copiloteleanorjboyd
andcommitted
Improve test code quality by removing any types
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent ac59e73 commit 559ecdf

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/test/managers/builtin/venvManager.unit.test.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import * as sinon from 'sinon';
33
import { LogOutputChannel } from 'vscode';
44
import { VenvManager } from '../../../managers/builtin/venvManager';
55
import * as helpers from '../../../managers/builtin/helpers';
6+
import { PythonEnvironmentApi } from '../../../api';
7+
import { NativePythonFinder } from '../../../managers/common/nativePythonFinder';
8+
import { EnvironmentManager } from '../../../api';
69

710
suite('VenvManager uv labeling tests', () => {
811
let sandbox: sinon.SinonSandbox;
@@ -20,12 +23,12 @@ suite('VenvManager uv labeling tests', () => {
2023
sandbox.stub(helpers, 'isUvInstalled').resolves(false);
2124

2225
// Create mocks for required dependencies
23-
const mockNativeFinder = {} as any;
24-
const mockApi = {} as any;
25-
const mockBaseManager = {} as any;
26+
const mockNativeFinder = {} as NativePythonFinder;
27+
const mockApi = {} as PythonEnvironmentApi;
28+
const mockBaseManager = {} as EnvironmentManager;
2629
const mockLog = {} as LogOutputChannel;
2730

28-
const mockInternalRefresh = sandbox.stub(VenvManager.prototype, 'internalRefresh' as any).resolves();
31+
const mockInternalRefresh = sandbox.stub(VenvManager.prototype, 'internalRefresh' as keyof VenvManager).resolves();
2932

3033
const manager = new VenvManager(mockNativeFinder, mockApi, mockBaseManager, mockLog);
3134

@@ -44,14 +47,14 @@ suite('VenvManager uv labeling tests', () => {
4447
sandbox.stub(helpers, 'isUvInstalled').resolves(true);
4548

4649
// Create mocks for required dependencies
47-
const mockNativeFinder = {} as any;
48-
const mockApi = {} as any;
49-
const mockBaseManager = {} as any;
50+
const mockNativeFinder = {} as NativePythonFinder;
51+
const mockApi = {} as PythonEnvironmentApi;
52+
const mockBaseManager = {} as EnvironmentManager;
5053
const mockLog = {
5154
info: sandbox.stub()
52-
} as any;
55+
} as unknown as LogOutputChannel;
5356

54-
const mockInternalRefresh = sandbox.stub(VenvManager.prototype, 'internalRefresh' as any).resolves();
57+
const mockInternalRefresh = sandbox.stub(VenvManager.prototype, 'internalRefresh' as keyof VenvManager).resolves();
5558

5659
const manager = new VenvManager(mockNativeFinder, mockApi, mockBaseManager, mockLog);
5760

@@ -63,22 +66,22 @@ suite('VenvManager uv labeling tests', () => {
6366
// Verify displayName is updated when uv is available
6467
assert.strictEqual(manager.displayName, 'venv [uv]');
6568
assert.ok(mockInternalRefresh.calledOnce);
66-
assert.ok(mockLog.info.calledWith('uv detected - updating venv manager display name'));
69+
assert.ok((mockLog as unknown as { info: sinon.SinonStub }).info.calledWith('uv detected - updating venv manager display name'));
6770
});
6871

6972
test('should only initialize once and preserve displayName', async () => {
7073
// Mock isUvInstalled to return true
7174
sandbox.stub(helpers, 'isUvInstalled').resolves(true);
7275

7376
// Create mocks for required dependencies
74-
const mockNativeFinder = {} as any;
75-
const mockApi = {} as any;
76-
const mockBaseManager = {} as any;
77+
const mockNativeFinder = {} as NativePythonFinder;
78+
const mockApi = {} as PythonEnvironmentApi;
79+
const mockBaseManager = {} as EnvironmentManager;
7780
const mockLog = {
7881
info: sandbox.stub()
79-
} as any;
82+
} as unknown as LogOutputChannel;
8083

81-
const mockInternalRefresh = sandbox.stub(VenvManager.prototype, 'internalRefresh' as any).resolves();
84+
const mockInternalRefresh = sandbox.stub(VenvManager.prototype, 'internalRefresh' as keyof VenvManager).resolves();
8285

8386
const manager = new VenvManager(mockNativeFinder, mockApi, mockBaseManager, mockLog);
8487

@@ -89,6 +92,6 @@ suite('VenvManager uv labeling tests', () => {
8992
// Verify displayName is set correctly and internal refresh is called only once
9093
assert.strictEqual(manager.displayName, 'venv [uv]');
9194
assert.ok(mockInternalRefresh.calledOnce);
92-
assert.ok(mockLog.info.calledOnce);
95+
assert.ok((mockLog as unknown as { info: sinon.SinonStub }).info.calledOnce);
9396
});
9497
});

0 commit comments

Comments
 (0)