Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for run plugin task command #1256

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export enum Commands {
RESET_PACKAGE = "swift.resetPackage",
USE_LOCAL_DEPENDENCY = "swift.useLocalDependency",
UNEDIT_DEPENDENCY = "swift.uneditDependency",
RUN_PLUGIN_TASK = "swift.runPluginTask",
}

/**
Expand Down Expand Up @@ -112,7 +113,7 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
}),
vscode.commands.registerCommand("swift.runSnippet", () => runSnippet(ctx)),
vscode.commands.registerCommand("swift.debugSnippet", () => debugSnippet(ctx)),
vscode.commands.registerCommand("swift.runPluginTask", () => runPluginTask()),
vscode.commands.registerCommand(Commands.RUN_PLUGIN_TASK, () => runPluginTask()),
vscode.commands.registerCommand("swift.restartLSPServer", () =>
ctx.languageClientManager.restart()
),
Expand Down
39 changes: 39 additions & 0 deletions test/integration-tests/commands/runPluginTask.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the VS Code Swift open source project
//
// Copyright (c) 2024 the VS Code Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import * as vscode from "vscode";
import { mockGlobalObject } from "../../MockUtils";
import { expect } from "chai";
import { activateExtensionForSuite, folderInRootWorkspace } from "../utilities/testutilities";
import { Commands } from "../../../src/commands";

suite("runPluginTask Test Suite", () => {
const executeCommand = vscode.commands.executeCommand;
const commandsMock = mockGlobalObject(vscode, "commands");

activateExtensionForSuite({
async setup(ctx) {
await folderInRootWorkspace("command-plugin", ctx);
},
});

test("Executes runTask command", async () => {
executeCommand(Commands.RUN_PLUGIN_TASK);

expect(commandsMock.executeCommand).to.have.been.calledOnceWith(
"workbench.action.tasks.runTask",
{ type: "swift-plugin" }
);
});
});
Loading