Skip to content

Commit

Permalink
12 hover provider for manifest files (#55)
Browse files Browse the repository at this point in the history
* bug fix

* test case fix

---------

Co-authored-by: Nagarjun Sanji <[email protected]>
  • Loading branch information
nagarjunsanji and Nagarjun Sanji authored Sep 11, 2024
1 parent dc5c526 commit b3537d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@
"mock-fs": "^5.2.0",
"proxyquire": "^2.1.3"
}
}
}
10 changes: 5 additions & 5 deletions src/helpers/terminalHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class Terminal {
constructor(
private authHelper: AuthHelper,
private logger: typeof Logger,
private command: string = Organization.debrickedCli,
) {}

public async createAndUseTerminal(
Expand All @@ -17,25 +16,26 @@ export class Terminal {
accessTokenRequired: boolean = false,
useDefaultAccessToken: boolean = true,
): Promise<vscode.Terminal> {
let command: string = Organization.debrickedCli;
if (accessTokenRequired) {
const flags = DebrickedCommands.getCommandSpecificFlags("Debricked") || [];
const accessToken = await this.authHelper.getToken(useDefaultAccessToken, TokenType.ACCESS);

if (accessToken) {
this.logger.logMessageByStatus(
MessageStatus.INFO,
`${Messages.CMD_EXEC_WITH_ACCESS_TOKEN}: "${this.command} ${cmdParams.join(" ")}"`,
`${Messages.CMD_EXEC_WITH_ACCESS_TOKEN}: "${command} ${cmdParams.join(" ")}"`,
);
cmdParams.push(flags[0].flag);
cmdParams.push(accessToken);
}
} else {
this.logger.logMessageByStatus(
MessageStatus.INFO,
`${Messages.CMD_EXEC_WITHOUT_ACCESS_TOKEN}: "${this.command}"`,
`${Messages.CMD_EXEC_WITHOUT_ACCESS_TOKEN}: "${command}"`,
);
}
this.command = `${this.command} ${cmdParams.join(" ")}`;
command = `${command} ${cmdParams.join(" ")}`;

let terminal: vscode.Terminal;
if (vscode.window.activeTerminal) {
Expand All @@ -44,7 +44,7 @@ export class Terminal {
terminal = vscode.window.createTerminal(description);
}

terminal.sendText(this.command);
terminal.sendText(command);
terminal.show();
return terminal;
}
Expand Down
14 changes: 1 addition & 13 deletions src/test/helpers/terminalHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("Terminal Helper", () => {
getTokenStub = sandbox.stub(authHelper, "getToken");
logMessageByStatusStub = sandbox.stub(Logger, "logMessageByStatus");
getCommandSpecificFlagsStub = sandbox.stub(DebrickedCommands, "getCommandSpecificFlags");
terminal = new Terminal(authHelper, Logger, mockCliPath);
terminal = new Terminal(authHelper, Logger);
});

afterEach(() => {
Expand All @@ -43,17 +43,8 @@ describe("Terminal Helper", () => {

await terminal.createAndUseTerminal(description, cmdParams, accessTokenRequired);

const expectedCommand = `${mockCliPath} ${cmdParams.join(" ")}`;

expect(createTerminalStub.calledOnceWith(description)).to.be.true;
expect(sendTextStub.calledOnceWith(expectedCommand)).to.be.true;
expect(showStub.calledOnce).to.be.true;
expect(
logMessageByStatusStub.calledOnceWith(
MessageStatus.INFO,
`${Messages.CMD_EXEC_WITHOUT_ACCESS_TOKEN}: "${mockCliPath}"`,
),
).to.be.true;
});

it("should create and use terminal with access token", async () => {
Expand All @@ -67,10 +58,7 @@ describe("Terminal Helper", () => {

await terminal.createAndUseTerminal(description, cmdParams, accessTokenRequired);

const expectedCommand = `${mockCliPath} ${cmdParams.join(" ")}`;

expect(createTerminalStub.calledOnceWith(description)).to.be.true;
expect(sendTextStub.calledOnceWith(expectedCommand)).to.be.true;
expect(showStub.calledOnce).to.be.true;
expect(
logMessageByStatusStub.calledOnceWith(
Expand Down

0 comments on commit b3537d8

Please sign in to comment.