Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Carneiro committed Dec 13, 2024
1 parent c7d0b5d commit 90b1f09
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/suite/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ describe("dataSourceCommand2", () => {
},
insightsNode: "dummyNode",
};
const dummyError = {
error: "error message",
};
const connMngService = new ConnectionManagementService();
const uriTest: vscode.Uri = vscode.Uri.parse("test");
const ab = new ArrayBuffer(26);
Expand Down Expand Up @@ -678,6 +681,44 @@ describe("dataSourceCommand2", () => {
.withArgs("No Insights active connection found");
});

it("should return error for visible results panel", async () => {
ext.connectedConnectionList.push(insightsConn);
retrieveConnStub.resolves(insightsConn);
insightsConn.meta = dummyMeta;
getMetaStub.resolves(dummyMeta);
sinon.stub(dataSourceCommand, "runQsqlDataSource").resolves(dummyError);

ext.isResultsTabVisible = true;
await dataSourceCommand.runDataSource(
dummyFileContent as DataSourceFiles,
insightsConn.connLabel,
"test-file.kdb.json",
);
sinon.assert.neverCalledWith(writeQueryResultsToConsoleStub);
sinon.assert.calledOnce(writeQueryResultsToViewStub);

ext.connectedConnectionList.length = 0;
});

it("should return error for console panel", async () => {
ext.connectedConnectionList.push(insightsConn);
retrieveConnStub.resolves(insightsConn);
insightsConn.meta = dummyMeta;
getMetaStub.resolves(dummyMeta);
sinon.stub(dataSourceCommand, "runQsqlDataSource").resolves(dummyError);

ext.isResultsTabVisible = false;
await dataSourceCommand.runDataSource(
dummyFileContent as DataSourceFiles,
insightsConn.connLabel,
"test-file.kdb.json",
);
sinon.assert.neverCalledWith(writeQueryResultsToViewStub);
sinon.assert.calledOnce(writeQueryResultsToConsoleStub);

ext.connectedConnectionList.length = 0;
});

it("should return QSQL results", async () => {
ext.connectedConnectionList.push(insightsConn);
retrieveConnStub.resolves(insightsConn);
Expand Down

0 comments on commit 90b1f09

Please sign in to comment.