Skip to content

Commit

Permalink
refactor(tests): Restore mocks after each test case
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 Sep 25, 2024
1 parent 8974ce2 commit 3a323ab
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,8 @@ describe("Profiles Unit Tests - function basicAuthClearSecureArray", () => {
expect(teamCfgMock.delete).toHaveBeenCalledWith(mergeArgsMock.knownArgs[1].argLoc.jsonLoc);
expect(teamCfgMock.set).toHaveBeenCalledWith(`${profAttrsMock.profLoc.jsonLoc}.secure`, ["tokenValue"]);
expect(teamCfgMock.save).toHaveBeenCalled();
getProfileInfoMock.mockRestore();
getProfileFromConfigMock.mockRestore();
});
it("calls Config APIs when profLoc.jsonLoc is valid, loginTokenType provided", async () => {
const teamCfgMock = {
Expand Down Expand Up @@ -2230,6 +2232,8 @@ describe("Profiles Unit Tests - function basicAuthClearSecureArray", () => {
expect(teamCfgMock.delete).toHaveBeenCalledWith(mergeArgsMock.knownArgs[1].argLoc.jsonLoc);
expect(teamCfgMock.set).toHaveBeenCalledWith(`${profAttrsMock.profLoc.jsonLoc}.secure`, []);
expect(teamCfgMock.save).toHaveBeenCalled();
getProfileInfoMock.mockRestore();
getProfileFromConfigMock.mockRestore();
});

it("does not call Config.set when profLoc.jsonLoc is invalid", async () => {
Expand Down Expand Up @@ -2271,7 +2275,9 @@ describe("Profiles Unit Tests - function basicAuthClearSecureArray", () => {
await Profiles.getInstance().basicAuthClearSecureArray("example_profile");
expect(teamCfgMock.delete).toHaveBeenCalledWith(mergeArgsMock.knownArgs[0].argLoc.jsonLoc);
expect(teamCfgMock.delete).toHaveBeenCalledWith(mergeArgsMock.knownArgs[1].argLoc.jsonLoc);
expect(teamCfgMock.set).not.toHaveBeenCalledWith(`${profAttrsMock.profLoc.jsonLoc}.secure`, ["tokenValue"]);
expect(teamCfgMock.set).not.toHaveBeenCalled();
expect(teamCfgMock.save).toHaveBeenCalled();
getProfileInfoMock.mockRestore();
getProfileFromConfigMock.mockRestore();
});
});

0 comments on commit 3a323ab

Please sign in to comment.