Add executeCommand to app container (#1857)

This commit is contained in:
Charis Kyriakou
2022-12-09 17:12:25 +00:00
committed by GitHub
parent ed76b46fa5
commit 1a0d88135d
3 changed files with 8 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import { AppEventEmitter } from "./events";
export interface App {
createEventEmitter<T>(): AppEventEmitter<T>;
executeCommand(command: string, ...args: any): Thenable<void>;
mode: AppMode;
subscriptions: Disposable[];
extensionPath: string;

View File

@@ -39,4 +39,8 @@ export class ExtensionApp implements App {
public createEventEmitter<T>(): AppEventEmitter<T> {
return new VSCodeAppEventEmitter<T>();
}
public executeCommand(command: string, ...args: any): Thenable<void> {
return vscode.commands.executeCommand(command, args);
}
}

View File

@@ -7,11 +7,13 @@ export function createMockApp({
workspaceStoragePath = "/mock/workspace/storage/path",
globalStoragePath = "/mock/global/storage/path",
createEventEmitter = <T>() => new MockAppEventEmitter<T>(),
executeCommand = jest.fn(() => Promise.resolve()),
}: {
extensionPath?: string;
workspaceStoragePath?: string;
globalStoragePath?: string;
createEventEmitter?: <T>() => AppEventEmitter<T>;
executeCommand?: () => Promise<void>;
}): App {
return {
mode: AppMode.Test,
@@ -20,6 +22,7 @@ export function createMockApp({
workspaceStoragePath,
globalStoragePath,
createEventEmitter,
executeCommand,
};
}