Skip to content

Commit

Permalink
Code Coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Likhitha Nimma <[email protected]>
  • Loading branch information
likhithanimma1 committed Nov 23, 2023
1 parent 1677a4c commit d1f4cbe
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ describe("UnixCommand Actions Unit Testing", () => {
});

showQuickPick.mockReturnValueOnce("firstName");
showInputBox.mockReturnValueOnce("/u/directorypath");
showInputBox.mockReturnValueOnce("/directorypath");
showInputBox.mockReturnValueOnce(undefined);

const mockCommandApi = await apiRegisterInstance.getCommandApi(profileOne);
Expand Down Expand Up @@ -455,6 +455,38 @@ describe("UnixCommand Actions Unit Testing", () => {
});
expect(showInputBox.mock.calls.length).toBe(1);
});
it("if path is not specified in the showInputBox", async () => {
Object.defineProperty(profileLoader.Profiles, "getInstance", {
value: jest.fn(() => {
return {
allProfiles: [{ name: "firstName", profile: { user: "firstName", password: "12345" } }, { name: "secondName" }],
defaultProfile: { name: "firstName" },
zosmfProfile: mockLoadNamedProfile,
checkCurrentProfile: jest.fn(() => {
return profilesForValidation;
}),
validateProfiles: jest.fn(),
getBaseProfile: jest.fn(),
getDefaultProfile: mockdefaultProfile,
validProfile: ValidProfileEnum.VALID,
};
}),
});
const mockCommandApi = await apiRegisterInstance.getCommandApi(profileOne);
const getCommandApiMock = jest.fn();
getCommandApiMock.mockReturnValue(mockCommandApi);
apiRegisterInstance.getCommandApi = getCommandApiMock.bind(apiRegisterInstance);

showQuickPick.mockReturnValueOnce("firstName");
showInputBox.mockReturnValueOnce(undefined);
showInputBox.mockReturnValueOnce("/d iplinfo1");

jest.spyOn(Gui, "resolveQuickPick").mockImplementation(() => Promise.resolve(qpItem));
jest.spyOn(mockCommandApi, "issueUnixCommand").mockReturnValue("iplinfo1" as any);

await unixActions.issueUnixCommand();
expect(showInformationMessage.mock.calls[0][0]).toEqual("Redirecting to Home Directory");
});

it("tests the issueUnixCommand function user does not select a profile", async () => {
Object.defineProperty(profileLoader.Profiles, "getInstance", {
Expand Down Expand Up @@ -516,6 +548,7 @@ describe("UnixCommand Actions Unit Testing", () => {
}),
});


jest.spyOn(unixActions, "checkCurrentProfile").mockReturnValue(undefined);

const mockCommandApi = await apiRegisterInstance.getCommandApi(profileOne);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"issueUnixCommand.outputchannel.title": "Zowe Unix Command",
"issueUnixCommand.quickPickOption": "Select the Profile to use to submit the Unix command",
"issueUnixCommand.cancelled": "Operation Cancelled",
"unixCommand.HomeDirectory": "Redirecting to Home Directory",
"issueUnixCommand.checkProfile": "Profile is invalid",
"issueUnixCommand.noProfilesLoaded": "No profiles available",
"path.notselected": "Enter a UNIX file filter search to enable Issue Unix Command from the tree view.",
Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer/src/command/UnixCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export class UnixCommandHandler extends ZoweCommandProvider {
value: "",
});
}
if (cwd == "") {
vscode.window.showInformationMessage("Redirecting to Home Directory");
if (cwd == undefined) {
Gui.showMessage(localize("unixCommand.HomeDirectory", "Redirecting to Home Directory"));
this.flag = false;
}
if (!node) {
Expand Down

0 comments on commit d1f4cbe

Please sign in to comment.