Skip to content

Commit

Permalink
add output channel in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome committed Nov 19, 2024
1 parent 4cf39a5 commit ca04555
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ const setWorkspaceGenerationContext = (params: Partial<WorkspaceGenerationContex

suite('GenerateClientCommand Test Suite', () => {
const sanbox = sinon.createSandbox();

let myOutputChannel = vscode.window.createOutputChannel("Kiota", {
log: true,
});
teardown(() => {
sanbox.restore();
});

test('test function getName of GenerateClientCommand', () => {
var treeProvider = sinon.createStubInstance(treeModule.OpenApiTreeProvider);
var viewProvider = sinon.createStubInstance(dependenciesModule.DependenciesViewProvider);
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext);
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext, myOutputChannel);
assert.strictEqual("kiota.openApiExplorer.generateClient", generateClientCommand.getName());
});

Expand All @@ -92,7 +94,7 @@ suite('GenerateClientCommand Test Suite', () => {
treeProvider.getSelectedPaths.returns([]);
var viewProvider = sinon.createStubInstance(dependenciesModule.DependenciesViewProvider);
const vscodeWindowSpy = sinon.stub(vscode.window, "showErrorMessage");
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext);
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext, myOutputChannel);
await generateClientCommand.execute();
assert.strictEqual((treeProvider.getSelectedPaths()).length, 0);
sinon.assert.calledOnceWithMatch(vscodeWindowSpy, vscode.l10n.t("No endpoints selected, select endpoints first"));
Expand All @@ -114,7 +116,7 @@ suite('GenerateClientCommand Test Suite', () => {
const generateStepsFn = sinon.stub(generateStepsModule, "generateSteps");
generateStepsFn.resolves(config);
const showUpgradeWarningMessageStub = sinon.stub(msgUtilitiesModule, "showUpgradeWarningMessage");
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext);
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext, myOutputChannel);
await generateClientCommand.execute();
assert.strictEqual((treeProvider.getSelectedPaths()).length, 1);
vscodeWindowSpy.verify();
Expand Down Expand Up @@ -162,7 +164,7 @@ suite('GenerateClientCommand Test Suite', () => {
deepLinkParamsHandler.setDeepLinkParams(pluginParams);

//stub and call generateCommand
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext);
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext, myOutputChannel);
const generatePluginAndRefreshUIExpectation = sinon.mock(generateClientCommand).expects(
"generatePluginAndRefreshUI").once().withArgs(
config, extensionSettings, "path/to/temp/folder", ["repairs"]
Expand Down Expand Up @@ -216,7 +218,7 @@ suite('GenerateClientCommand Test Suite', () => {
deepLinkParamsHandler.setDeepLinkParams(pluginParams);

//stub and call generateCommand
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext);
const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext, myOutputChannel);
var outputPath = path.join("path", "to", "temp", "folder", "appPackage"); //make it os agnostic
const generateManifestAndRefreshUIExpectation = sinon.mock(generateClientCommand).expects(
"generateManifestAndRefreshUI").twice().withArgs(
Expand Down

0 comments on commit ca04555

Please sign in to comment.