Skip to content

Commit 40ca44f

Browse files
committed
test
1 parent 122680e commit 40ca44f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ suite('Terminal Service', () => {
4444
let pythonConfig: TypeMoq.IMock<WorkspaceConfiguration>;
4545
let editorConfig: TypeMoq.IMock<WorkspaceConfiguration>;
4646
let isWindowsStub: sinon.SinonStub;
47+
let isWslStub: sinon.SinonStub;
4748

4849
setup(() => {
4950
terminal = TypeMoq.Mock.ofType<VSCodeTerminal>();
@@ -97,6 +98,7 @@ suite('Terminal Service', () => {
9798
mockServiceContainer.setup((c) => c.get(ITerminalAutoActivation)).returns(() => terminalAutoActivator.object);
9899
getConfigurationStub = sinon.stub(workspaceApis, 'getConfiguration');
99100
isWindowsStub = sinon.stub(platform, 'isWindows');
101+
isWslStub = sinon.stub(platform, 'isWsl');
100102
pythonConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
101103
editorConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
102104
getConfigurationStub.callsFake((section: string) => {
@@ -278,6 +280,29 @@ suite('Terminal Service', () => {
278280
terminal.verify((t) => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(1));
279281
});
280282

283+
test('Ensure sendText IS called even when Python shell integration and terminal shell integration are both enabled - WSL', async () => {
284+
isWindowsStub.returns(false);
285+
isWslStub.returns(true);
286+
pythonConfig
287+
.setup((p) => p.get('terminal.shellIntegration.enabled'))
288+
.returns(() => true)
289+
.verifiable(TypeMoq.Times.once());
290+
291+
terminalHelper
292+
.setup((helper) => helper.getEnvironmentActivationCommands(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
293+
.returns(() => Promise.resolve(undefined));
294+
service = new TerminalService(mockServiceContainer.object);
295+
const textToSend = 'Some Text';
296+
terminalHelper.setup((h) => h.identifyTerminalShell(TypeMoq.It.isAny())).returns(() => TerminalShellType.bash);
297+
terminalManager.setup((t) => t.createTerminal(TypeMoq.It.isAny())).returns(() => terminal.object);
298+
299+
service.ensureTerminal();
300+
service.executeCommand(textToSend, true);
301+
302+
terminal.verify((t) => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(1));
303+
terminal.verify((t) => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(1));
304+
});
305+
281306
test('Ensure terminal is not shown if `hideFromUser` option is set to `true`', async () => {
282307
terminalHelper
283308
.setup((helper) => helper.getEnvironmentActivationCommands(TypeMoq.It.isAny(), TypeMoq.It.isAny()))

0 commit comments

Comments
 (0)