Skip to content

Commit 620c538

Browse files
bjaspanBarry Jaspanpre-commit-ci-lite[bot]
authored
Move vscode-common's TestHelpers interface to its own file. (#2032)
This makes it easier to excise the related test-specific code from the repo. --------- Co-authored-by: Barry Jaspan <[email protected]> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 024b5de commit 620c538

File tree

3 files changed

+57
-54
lines changed

3 files changed

+57
-54
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import type {
2+
CommandServerApi,
3+
ExcludableSnapshotField,
4+
ExtraSnapshotField,
5+
HatTokenMap,
6+
IDE,
7+
NormalizedIDE,
8+
ScopeProvider,
9+
SerializedMarks,
10+
TargetPlainObject,
11+
TestCaseSnapshot,
12+
TextEditor,
13+
} from "@cursorless/common";
14+
import * as vscode from "vscode";
15+
import { VscodeApi } from "./VscodeApi";
16+
17+
export interface TestHelpers {
18+
ide: NormalizedIDE;
19+
injectIde: (ide: IDE) => void;
20+
21+
scopeProvider: ScopeProvider;
22+
23+
hatTokenMap: HatTokenMap;
24+
25+
commandServerApi: CommandServerApi;
26+
27+
toVscodeEditor(editor: TextEditor): vscode.TextEditor;
28+
29+
setStoredTarget(
30+
editor: vscode.TextEditor,
31+
key: string,
32+
targets: TargetPlainObject[] | undefined,
33+
): void;
34+
35+
// FIXME: Remove this once we have a better way to get this function
36+
// accessible from our tests
37+
takeSnapshot(
38+
excludeFields: ExcludableSnapshotField[],
39+
extraFields: ExtraSnapshotField[],
40+
editor: TextEditor,
41+
ide: IDE,
42+
marks: SerializedMarks | undefined,
43+
forceRealClipboard: boolean,
44+
): Promise<TestCaseSnapshot>;
45+
46+
runIntegrationTests(): Promise<void>;
47+
48+
cursorlessTalonStateJsonPath: string;
49+
50+
/**
51+
* A thin wrapper around the VSCode API that allows us to mock it for testing.
52+
*/
53+
vscodeApi: VscodeApi;
54+
}

packages/vscode-common/src/getExtensionApi.ts

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,7 @@
1-
import type {
2-
CommandServerApi,
3-
ExcludableSnapshotField,
4-
ExtraSnapshotField,
5-
HatTokenMap,
6-
IDE,
7-
NormalizedIDE,
8-
ScopeProvider,
9-
SerializedMarks,
10-
SnippetMap,
11-
TargetPlainObject,
12-
TestCaseSnapshot,
13-
TextEditor,
14-
} from "@cursorless/common";
1+
import type { CommandServerApi, SnippetMap } from "@cursorless/common";
152
import * as vscode from "vscode";
163
import type { Language, SyntaxNode, Tree } from "web-tree-sitter";
17-
import { VscodeApi } from "./VscodeApi";
18-
19-
export interface TestHelpers {
20-
ide: NormalizedIDE;
21-
injectIde: (ide: IDE) => void;
22-
23-
scopeProvider: ScopeProvider;
24-
25-
hatTokenMap: HatTokenMap;
26-
27-
commandServerApi: CommandServerApi;
28-
29-
toVscodeEditor(editor: TextEditor): vscode.TextEditor;
30-
31-
setStoredTarget(
32-
editor: vscode.TextEditor,
33-
key: string,
34-
targets: TargetPlainObject[] | undefined,
35-
): void;
36-
37-
// FIXME: Remove this once we have a better way to get this function
38-
// accessible from our tests
39-
takeSnapshot(
40-
excludeFields: ExcludableSnapshotField[],
41-
extraFields: ExtraSnapshotField[],
42-
editor: TextEditor,
43-
ide: IDE,
44-
marks: SerializedMarks | undefined,
45-
forceRealClipboard: boolean,
46-
): Promise<TestCaseSnapshot>;
47-
48-
runIntegrationTests(): Promise<void>;
49-
50-
cursorlessTalonStateJsonPath: string;
51-
52-
/**
53-
* A thin wrapper around the VSCode API that allows us to mock it for testing.
54-
*/
55-
vscodeApi: VscodeApi;
56-
}
4+
import { TestHelpers } from "./TestHelpers";
575

586
export interface CursorlessApi {
597
testHelpers: TestHelpers | undefined;

packages/vscode-common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./getExtensionApi";
2+
export * from "./TestHelpers";
23
export * from "./notebook";
34
export * from "./testUtil/openNewEditor";
45
export * from "./vscodeUtil";

0 commit comments

Comments
 (0)