From 51cc27312782aea0935a2dde23632ae4ea1084d1 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Tue, 14 Nov 2023 17:01:56 -0500 Subject: [PATCH] Move vscode-common's TestHelpers interface to its own file. --- packages/vscode-common/src/TestHelpers.ts | 54 +++++++++++++++++++ packages/vscode-common/src/getExtensionApi.ts | 51 +----------------- packages/vscode-common/src/index.ts | 1 + 3 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 packages/vscode-common/src/TestHelpers.ts diff --git a/packages/vscode-common/src/TestHelpers.ts b/packages/vscode-common/src/TestHelpers.ts new file mode 100644 index 0000000000..bec02e6308 --- /dev/null +++ b/packages/vscode-common/src/TestHelpers.ts @@ -0,0 +1,54 @@ +import type { + CommandServerApi, + ExcludableSnapshotField, + ExtraSnapshotField, + HatTokenMap, + IDE, + NormalizedIDE, + ScopeProvider, + SerializedMarks, TargetPlainObject, + TestCaseSnapshot, + TextEditor +} from "@cursorless/common"; +import * as vscode from "vscode"; +import {VscodeApi} from "./VscodeApi"; + + +export interface TestHelpers { + ide: NormalizedIDE; + injectIde: (ide: IDE) => void; + + scopeProvider: ScopeProvider; + + hatTokenMap: HatTokenMap; + + commandServerApi: CommandServerApi; + + toVscodeEditor(editor: TextEditor): vscode.TextEditor; + + setStoredTarget( + editor: vscode.TextEditor, + key: string, + targets: TargetPlainObject[] | undefined + ): void; + + // FIXME: Remove this once we have a better way to get this function + // accessible from our tests + takeSnapshot( + excludeFields: ExcludableSnapshotField[], + extraFields: ExtraSnapshotField[], + editor: TextEditor, + ide: IDE, + marks: SerializedMarks | undefined, + forceRealClipboard: boolean + ): Promise; + + runIntegrationTests(): Promise; + + cursorlessTalonStateJsonPath: string; + + /** + * A thin wrapper around the VSCode API that allows us to mock it for testing. + */ + vscodeApi: VscodeApi; +} diff --git a/packages/vscode-common/src/getExtensionApi.ts b/packages/vscode-common/src/getExtensionApi.ts index c88b1b0b3d..ea9a40f890 100644 --- a/packages/vscode-common/src/getExtensionApi.ts +++ b/packages/vscode-common/src/getExtensionApi.ts @@ -1,59 +1,10 @@ import type { CommandServerApi, - ExcludableSnapshotField, - ExtraSnapshotField, - HatTokenMap, - IDE, - NormalizedIDE, - ScopeProvider, - SerializedMarks, SnippetMap, - TargetPlainObject, - TestCaseSnapshot, - TextEditor, } from "@cursorless/common"; import * as vscode from "vscode"; import type { Language, SyntaxNode, Tree } from "web-tree-sitter"; -import { VscodeApi } from "./VscodeApi"; - -export interface TestHelpers { - ide: NormalizedIDE; - injectIde: (ide: IDE) => void; - - scopeProvider: ScopeProvider; - - hatTokenMap: HatTokenMap; - - commandServerApi: CommandServerApi; - - toVscodeEditor(editor: TextEditor): vscode.TextEditor; - - setStoredTarget( - editor: vscode.TextEditor, - key: string, - targets: TargetPlainObject[] | undefined, - ): void; - - // FIXME: Remove this once we have a better way to get this function - // accessible from our tests - takeSnapshot( - excludeFields: ExcludableSnapshotField[], - extraFields: ExtraSnapshotField[], - editor: TextEditor, - ide: IDE, - marks: SerializedMarks | undefined, - forceRealClipboard: boolean, - ): Promise; - - runIntegrationTests(): Promise; - - cursorlessTalonStateJsonPath: string; - - /** - * A thin wrapper around the VSCode API that allows us to mock it for testing. - */ - vscodeApi: VscodeApi; -} +import {TestHelpers} from "./TestHelpers"; export interface CursorlessApi { testHelpers: TestHelpers | undefined; diff --git a/packages/vscode-common/src/index.ts b/packages/vscode-common/src/index.ts index c6a679e3bc..ca15cb6dad 100644 --- a/packages/vscode-common/src/index.ts +++ b/packages/vscode-common/src/index.ts @@ -1,4 +1,5 @@ export * from "./getExtensionApi"; +export * from "./TestHelpers"; export * from "./notebook"; export * from "./testUtil/openNewEditor"; export * from "./vscodeUtil";