Skip to content

Commit

Permalink
Move vscode-common's TestHelpers interface to its own file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Jaspan committed Nov 14, 2023
1 parent a59841b commit 51cc273
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 50 deletions.
54 changes: 54 additions & 0 deletions packages/vscode-common/src/TestHelpers.ts
Original file line number Diff line number Diff line change
@@ -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<TestCaseSnapshot>;

runIntegrationTests(): Promise<void>;

cursorlessTalonStateJsonPath: string;

/**
* A thin wrapper around the VSCode API that allows us to mock it for testing.
*/
vscodeApi: VscodeApi;
}
51 changes: 1 addition & 50 deletions packages/vscode-common/src/getExtensionApi.ts
Original file line number Diff line number Diff line change
@@ -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<TestCaseSnapshot>;

runIntegrationTests(): Promise<void>;

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;
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./getExtensionApi";
export * from "./TestHelpers";
export * from "./notebook";
export * from "./testUtil/openNewEditor";
export * from "./vscodeUtil";
Expand Down

0 comments on commit 51cc273

Please sign in to comment.