From d05d8669696812d67a3914fffb2289c178b2564e Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Mon, 16 May 2022 15:10:59 +0800 Subject: [PATCH] refactor: extract command --- src/commands.ts | 4 ++++ src/extension.ts | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/commands.ts diff --git a/src/commands.ts b/src/commands.ts new file mode 100644 index 00000000..e64f4d6d --- /dev/null +++ b/src/commands.ts @@ -0,0 +1,4 @@ +export enum Command { + StartWatching = "vitest.startWatching", + UpdateSnapshot = "vitest.updateSnapshot", +} diff --git a/src/extension.ts b/src/extension.ts index 0f2bc451..fbe725d9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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 ( @@ -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(); @@ -61,7 +62,7 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push( testWatcher, vscode.commands.registerCommand( - "vitest.startWatching", + Command.StartWatching, () => { testWatcher!.watch(); }, @@ -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); },