Skip to content

Commit

Permalink
fix Profiles failing unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Billie Simmons <[email protected]>
  • Loading branch information
JillieBeanSim committed Dec 15, 2023
1 parent d27788f commit 523500f
Showing 1 changed file with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,41 +292,13 @@ describe("Profiles Unit Tests - Function createZoweSession", () => {
hide: jest.fn(),
value: "test",
} as any);
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce(new utils.FilterDescriptor("Test1"));
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce(new utils.FilterDescriptor("Test2"));
jest.spyOn(Profiles.getInstance(), "getProfileInfo").mockResolvedValue({
usingTeamConfig: false,
} as any);
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce(new utils.FilterDescriptor("Test"));
jest.spyOn(Profiles.getInstance(), "getProfileInfo").mockResolvedValueOnce(createInstanceOfProfileInfo());
jest.spyOn(Gui, "showInputBox").mockResolvedValue("test");
jest.spyOn(Profiles.getInstance(), "createNewConnection").mockResolvedValue("Test");
const refreshSpy = jest.spyOn(Profiles.getInstance(), "refresh").mockImplementation();
jest.spyOn(ProfileManagement, "handleChangeForAllTrees").mockResolvedValue(true);
jest.spyOn(TreeProviders, "providers", "get").mockReturnValue({
ds: { addSingleSession: jest.fn(), mSessionNodes: [...globalMocks.testUSSTree.mSessionNodes], refresh: jest.fn() } as any,
uss: { addSingleSession: jest.fn(), mSessionNodes: [...globalMocks.testUSSTree.mSessionNodes], refresh: jest.fn() } as any,
jobs: { addSingleSession: jest.fn(), mSessionNodes: [...globalMocks.testUSSTree.mSessionNodes], refresh: jest.fn() } as any,
} as any);
await expect(Profiles.getInstance().createZoweSession(globalMocks.testUSSTree)).resolves.not.toThrow();
expect(refreshSpy).toBeCalledTimes(1);
expect(spyInfo).toBeCalledWith("New profile created, test.");
refreshSpy.mockClear();
spyInfo.mockClear();
jest.spyOn(Gui, "resolveQuickPick").mockReset();
});

it("Tests that createZoweSession runs successfully and uses the chosenProfile", async () => {
const globalMocks = await createGlobalMocks();
jest.spyOn(Gui, "createQuickPick").mockReturnValue({
show: jest.fn(),
hide: jest.fn(),
value: "test",
} as any);
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce({ label: "test" });
const spyInfo = jest.spyOn(ZoweLogger, "info");
jest.spyOn(ProfileManagement, "handleChangeForAllTrees").mockResolvedValue(true);
await expect(Profiles.getInstance().createZoweSession(globalMocks.testUSSTree)).resolves.not.toThrow();
expect(spyInfo).toBeCalledWith("The profile test has been added to the zowe.uss.history tree.");
spyInfo.mockClear();
expect(spyConfig).toBeCalled();
spyConfig.mockClear();
});

it("Tests that createZoweSession catches error and log warning", async () => {
Expand Down

0 comments on commit 523500f

Please sign in to comment.