Skip to content

Commit

Permalink
refactor: clear 'defaultProfileByType', update test
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
  • Loading branch information
traeok committed Mar 25, 2024
1 parent 1db37a9 commit ce52b02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,15 @@ describe("ProfilesCache", () => {
expect(mockLogError).toHaveBeenCalledWith(fakeError);
});

it("should clear the profilesByType map before reloading profiles", async () => {
it("should clear the profilesByType and defaultProfileByType maps before reloading profiles", async () => {
const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as zowe.imperative.Logger);
const profInfoMock = jest.spyOn(profCache, "getProfileInfo").mockRejectedValueOnce("some error");
const errorMock = jest.spyOn((profCache as any).log, "error").mockImplementation();
(profCache as any).profilesByType["test-type"] = { name: "someProf" as any };
(profCache as any).defaultProfileByType["test-type"] = { name: "someProf" as any };
await profCache.refresh();
expect((profCache as any).profilesByType.size).toBe(0);
expect((profCache as any).defaultProfileByType.size).toBe(0);
expect(errorMock).toHaveBeenCalledWith("some error");
profInfoMock.mockRestore();
errorMock.mockRestore();
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class ProfilesCache {
this.allProfiles = [];
this.allTypes = [];
this.profilesByType.clear();
this.defaultProfileByType.clear();
let mProfileInfo: zowe.imperative.ProfileInfo;
try {
mProfileInfo = await this.getProfileInfo();
Expand Down

0 comments on commit ce52b02

Please sign in to comment.