Skip to content

Commit

Permalink
onDidEndTerminalShellExecution never gets fired
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed Sep 11, 2024
1 parent a75656b commit a51b6b4
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions src/test/common/terminals/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ suite('Terminal Service', () => {
let mockServiceContainer: TypeMoq.IMock<IServiceContainer>;
let terminalAutoActivator: TypeMoq.IMock<ITerminalAutoActivation>;
let terminalShellIntegration: TypeMoq.IMock<TerminalShellIntegration>;
// let onDidEndTerminalShellExecutionEmitter: EventEmitter<TerminalShellExecutionEndEvent>;
// let event: TerminalShellExecutionEndEvent;
let onDidEndTerminalShellExecutionEmitter: EventEmitter<TerminalShellExecutionEndEvent>;
let event: TerminalShellExecutionEndEvent;
setup(() => {
terminal = TypeMoq.Mock.ofType<VSCodeTerminal>();
terminalShellIntegration = TypeMoq.Mock.ofType<TerminalShellIntegration>();
// terminal.setup((t) => t.shellIntegration).returns(() => terminalShellIntegration.object);
terminal.setup((t) => t.shellIntegration).returns(() => undefined);
terminal.setup((t) => t.shellIntegration).returns(() => terminalShellIntegration.object);
// terminal.setup((t) => t.shellIntegration).returns(() => undefined);
const shellExecution: TypeMoq.IMock<TerminalShellExecution> = TypeMoq.Mock.ofType<TerminalShellExecution>();

terminalShellIntegration
Expand All @@ -51,36 +51,34 @@ suite('Terminal Service', () => {

terminalManager = TypeMoq.Mock.ofType<ITerminalManager>();
// terminalManager.setup((t) => t.onDidEndTerminalShellExecution(TypeMoq.It.isAny()))
const onDidEndTerminalShellExecutionEmitter = new EventEmitter<TerminalShellExecutionEndEvent>();
onDidEndTerminalShellExecutionEmitter = new EventEmitter<TerminalShellExecutionEndEvent>();
terminalManager
.setup((t) => t.onDidEndTerminalShellExecution(TypeMoq.It.isAny()))
.callback((handler) => {
onDidEndTerminalShellExecutionEmitter.event(handler);
});

// const execution: TerminalShellExecution = {
// commandLine: {
// value: 'dummy text',
// isTrusted: true,
// confidence: 2,
// },
// cwd: undefined,
// read: function (): AsyncIterable<string> {
// throw new Error('Function not implemented.');
// },
// };
// const exitCode = 0;

// // Mock the execution object and exitCode
// event = {
// execution,
// exitCode,
// terminal: terminal.object,
// shellIntegration: terminalShellIntegration.object,
// };

// // Trigger the event
// onDidEndTerminalShellExecutionEmitter.fire(event);
.setup((t) => t.onDidEndTerminalShellExecution)
.returns(() => onDidEndTerminalShellExecutionEmitter.event);

const execution: TerminalShellExecution = {
commandLine: {
value: 'dummy text',
isTrusted: true,
confidence: 2,
},
cwd: undefined,
read: function (): AsyncIterable<string> {
throw new Error('Function not implemented.');
},
};
const exitCode = 0;

// Mock the execution object and exitCode
event = {
execution,
exitCode,
terminal: terminal.object,
shellIntegration: terminalShellIntegration.object,
};

// Trigger the event
onDidEndTerminalShellExecutionEmitter.fire(event);

platformService = TypeMoq.Mock.ofType<IPlatformService>();
workspaceService = TypeMoq.Mock.ofType<IWorkspaceService>();
Expand Down

0 comments on commit a51b6b4

Please sign in to comment.