Skip to content

Commit

Permalink
refactor: extract command
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed May 16, 2022
1 parent 87819ea commit d05d866
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum Command {
StartWatching = "vitest.startWatching",
UpdateSnapshot = "vitest.updateSnapshot",
}
7 changes: 4 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { debugHandler, runHandler, updateSnapshot } from "./runHandler";
import { TestFile, WEAKMAP_TEST_DATA } from "./TestData";
import semver from "semver";
import { TestWatcher } from "./watch";
import { Command } from "./commands";

export async function activate(context: vscode.ExtensionContext) {
if (
Expand All @@ -26,7 +27,7 @@ export async function activate(context: vscode.ExtensionContext) {

const ctrl = vscode.tests.createTestController(
`${extensionId}`,
"Vitest Test Provider",
"Vitest",
);

const fileDiscoverer = new TestFileDiscoverer();
Expand Down Expand Up @@ -61,7 +62,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
testWatcher,
vscode.commands.registerCommand(
"vitest.startWatching",
Command.StartWatching,
() => {
testWatcher!.watch();
},
Expand Down Expand Up @@ -97,7 +98,7 @@ export async function activate(context: vscode.ExtensionContext) {
(e) => fileDiscoverer.discoverTestFromDoc(ctrl, e.document),
),
vscode.commands.registerCommand(
"vitest.updateSnapshot",
Command.UpdateSnapshot,
(test) => {
updateSnapshot(ctrl, test);
},
Expand Down

0 comments on commit d05d866

Please sign in to comment.