Skip to content

Commit 48de3b3

Browse files
committed
fix test
1 parent f15928c commit 48de3b3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/client/common/terminal/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class TerminalService implements ITerminalService, Disposable {
101101
});
102102
await promise;
103103
}
104-
104+
//breaking test
105105
const config = getConfiguration('python');
106106
const pythonrcSetting = config.get<boolean>('terminal.shellIntegration.enabled');
107107
if (isPythonShell && !pythonrcSetting) {

src/test/common/terminals/service.unit.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { expect } from 'chai';
55
import * as path from 'path';
6+
import * as sinon from 'sinon';
67
import * as TypeMoq from 'typemoq';
78
import {
89
Disposable,
@@ -22,6 +23,7 @@ import { IDisposableRegistry } from '../../../client/common/types';
2223
import { IServiceContainer } from '../../../client/ioc/types';
2324
import { ITerminalAutoActivation } from '../../../client/terminals/types';
2425
import { createPythonInterpreter } from '../../utils/interpreters';
26+
import * as workspaceApis from '../../../client/common/vscodeApis/workspaceApis';
2527

2628
suite('Terminal Service', () => {
2729
let service: TerminalService;
@@ -37,6 +39,9 @@ suite('Terminal Service', () => {
3739
let terminalShellIntegration: TypeMoq.IMock<TerminalShellIntegration>;
3840
let onDidEndTerminalShellExecutionEmitter: EventEmitter<TerminalShellExecutionEndEvent>;
3941
let event: TerminalShellExecutionEndEvent;
42+
let getConfigurationStub: sinon.SinonStub;
43+
let pythonConfig: TypeMoq.IMock<WorkspaceConfiguration>;
44+
let editorConfig: TypeMoq.IMock<WorkspaceConfiguration>;
4045

4146
setup(() => {
4247
terminal = TypeMoq.Mock.ofType<VSCodeTerminal>();
@@ -88,12 +93,22 @@ suite('Terminal Service', () => {
8893
mockServiceContainer.setup((c) => c.get(IWorkspaceService)).returns(() => workspaceService.object);
8994
mockServiceContainer.setup((c) => c.get(ITerminalActivator)).returns(() => terminalActivator.object);
9095
mockServiceContainer.setup((c) => c.get(ITerminalAutoActivation)).returns(() => terminalAutoActivator.object);
96+
getConfigurationStub = sinon.stub(workspaceApis, 'getConfiguration');
97+
pythonConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
98+
editorConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
99+
getConfigurationStub.callsFake((section: string) => {
100+
if (section === 'python') {
101+
return pythonConfig.object;
102+
}
103+
return editorConfig.object;
104+
});
91105
});
92106
teardown(() => {
93107
if (service) {
94108
service.dispose();
95109
}
96110
disposables.filter((item) => !!item).forEach((item) => item.dispose());
111+
sinon.restore();
97112
});
98113

99114
test('Ensure terminal is disposed', async () => {
@@ -103,13 +118,15 @@ suite('Terminal Service', () => {
103118
const os: string = 'windows';
104119
service = new TerminalService(mockServiceContainer.object);
105120
const shellPath = 'powershell.exe';
121+
// TODO: switch over legacy Terminal code to use workspace getConfiguration from workspaceApis instead of directly from vscode.workspace
106122
workspaceService
107123
.setup((w) => w.getConfiguration(TypeMoq.It.isValue('terminal.integrated.shell')))
108124
.returns(() => {
109125
const workspaceConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
110126
workspaceConfig.setup((c) => c.get(os)).returns(() => shellPath);
111127
return workspaceConfig.object;
112128
});
129+
pythonConfig.setup((p) => p.get('terminal.shellIntegration.enabled')).returns(() => false);
113130

114131
platformService.setup((p) => p.isWindows).returns(() => os === 'windows');
115132
platformService.setup((p) => p.isLinux).returns(() => os === 'linux');
@@ -134,6 +151,7 @@ suite('Terminal Service', () => {
134151
});
135152

136153
test('Ensure command is sent to terminal and it is shown', async () => {
154+
pythonConfig.setup((p) => p.get('terminal.shellIntegration.enabled')).returns(() => false);
137155
terminalHelper
138156
.setup((helper) => helper.getEnvironmentActivationCommands(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
139157
.returns(() => Promise.resolve(undefined));

0 commit comments

Comments
 (0)