Skip to content

Commit

Permalink
chore: more unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
  • Loading branch information
zFernand0 committed Oct 22, 2024
1 parent 257254b commit 819e742
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ describe("UnixCommand Actions Unit Testing", () => {

expect(showInputBox.mock.calls.length).toBe(2);
expect(appendLine.mock.calls.length).toBe(2);
expect(appendLine.mock.calls[0][0]).toBe("> testUser@firstProfile:/u/directorypath$ /d iplinfo1");
expect(appendLine.mock.calls[0][0]).toBe("> testUser@firstProfile:/u/directorypath $ /d iplinfo1");
expect(appendLine.mock.calls[1][0]["commandResponse"]).toBe("iplinfo1");
expect(showInformationMessage.mock.calls.length).toBe(0);
});
Expand All @@ -286,7 +286,7 @@ describe("UnixCommand Actions Unit Testing", () => {
});
});

fit("tests the issueUnixCommand function user selects a history item", async () => {
it("tests the issueUnixCommand function user selects a history item", async () => {
const mockUssApi = await apiRegisterInstance.getUssApi(profileOne);
const getUssApiMock = jest.fn();
getUssApiMock.mockReturnValue(mockUssApi);
Expand Down Expand Up @@ -452,10 +452,10 @@ describe("UnixCommand Actions Unit Testing", () => {

await getUnixActions().issueUnixCommand();

expect(showInformationMessage.mock.calls[0][0]).toEqual("Operation Cancelled");
expect(showInformationMessage.mock.calls[0][0]).toEqual("Operation cancelled");
});

fit("tests the issueUnixCommand function user starts typing a value in quick pick", async () => {
it("tests the issueUnixCommand function user starts typing a value in quick pick", async () => {
createQuickPick.mockReturnValueOnce({
placeholder: 'Choose "Create new..." to define a new profile or select an existing profile to add to the Data Set Explorer',
activeItems: [qpItem2],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
*/

import * as vscode from "vscode";
import { Gui, imperative, ProfilesCache, ZoweTreeNode } from "@zowe/zowe-explorer-api";
import { Gui, ProfilesCache, ZoweTreeNode } from "@zowe/zowe-explorer-api";
import { createIProfile, createISession } from "../../__mocks__/mockCreators/shared";
import { ICommandProviderDialogs, ZoweCommandProvider } from "../../../src/commands/ZoweCommandProvider";
import { ZoweCommandProvider } from "../../../src/commands/ZoweCommandProvider";
import { Profiles } from "../../../src/configuration/Profiles";
import { ZoweDatasetNode } from "../../../src/trees/dataset/ZoweDatasetNode";
import { SharedContext } from "../../../src/trees/shared/SharedContext";
import { createIJobFile } from "../../__mocks__/mockCreators/jobs";
import { AuthUtils } from "../../../src/utils/AuthUtils";
import { SettingsConfig } from "../../../src/configuration/SettingsConfig";

const globalMocks = {
testSession: createISession(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ describe("ZoweTerminal Unit Tests", () => {
iTerm.handleInput("002");
iTerm.handleInput(ZoweTerminal.Keys.ENTER);
expect(spyCb).toHaveBeenCalledWith("old002");
// expect((iTerm as any).mHistory as string[]).toContain("old002");
// expect((iTerm as any).mHistory as string[]).toContain("test002");
spyCb.mockClear();

iTerm.handleInput(ZoweTerminal.Keys.UP);
iTerm.handleInput(ZoweTerminal.Keys.UP);
iTerm.handleInput(ZoweTerminal.Keys.DOWN);
iTerm.handleInput(ZoweTerminal.Keys.LEFT);
Expand All @@ -43,10 +44,18 @@ describe("ZoweTerminal Unit Tests", () => {
iTerm.handleInput(ZoweTerminal.Keys.RIGHT);
iTerm.handleInput(ZoweTerminal.Keys.BACKSPACE);
iTerm.handleInput("11");
iTerm.handleInput(ZoweTerminal.Keys.BACKSPACE);
iTerm.handleInput(ZoweTerminal.Keys.ENTER);
expect(spyCb).toHaveBeenCalledWith("11");
expect(spyCb).toHaveBeenCalledWith("1");
// expect(spyCb).toHaveBeenCalledWith("test12");
spyCb.mockClear();

(iTerm as any).command = "";
iTerm.handleInput(ZoweTerminal.Keys.ENTER);
iTerm.handleInput(ZoweTerminal.Keys.CTRL_C);
iTerm.handleInput(":clear");
iTerm.handleInput(ZoweTerminal.Keys.ENTER);
iTerm.handleInput(":exit");
iTerm.handleInput(ZoweTerminal.Keys.ENTER);
});
});
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/tools/ZoweTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ZoweTerminal implements vscode.Pseudoterminal {
if (cmd === ":clear") {
this.clear();
} else if (cmd === ":exit") {
this.closeEmitter.fire();
this.close();
}
} else {
const output = await this.processCmd(cmd);
Expand Down

0 comments on commit 819e742

Please sign in to comment.