Skip to content

Commit

Permalink
fix some 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 9, 2024
1 parent 8877e9f commit d55b15c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe("AttributeView unit tests", () => {
});
const updateAttrsApiMock = jest.fn();
const updateAttributesMock = jest.spyOn(node, "setAttributes").mockImplementation();
const getAttributesMock = jest.spyOn(node, "getAttributes");
const attrError = new Error("Failed to update attributes");

beforeAll(() => {
jest.spyOn(ZoweExplorerApiRegister, "getUssApi").mockReturnValue({
Expand Down Expand Up @@ -64,7 +66,7 @@ describe("AttributeView unit tests", () => {
group: "group",
perms: "-rwxrwxrwx",
};
const getAttributesMock = jest.spyOn(ZoweUSSNode.prototype, "getAttributes").mockResolvedValue(attrs as any);
getAttributesMock.mockResolvedValue(attrs as any);
await (view as any).onDidReceiveMessage({ command: "ready" });
expect(view.panel.webview.postMessage).toHaveBeenCalledWith({
attributes: attrs,
Expand All @@ -75,7 +77,6 @@ describe("AttributeView unit tests", () => {
});

it("updates attributes when 'update-attributes' command is received", async () => {
const getAttributesMock = jest.spyOn(ZoweUSSNode.prototype, "getAttributes");
// case 1: no attributes provided from webview (sanity check)
updateAttrsApiMock.mockClear();
await (view as any).onDidReceiveMessage({ command: "update-attributes" });
Expand Down Expand Up @@ -112,8 +113,7 @@ describe("AttributeView unit tests", () => {
});

it("handles any errors while updating attributes", async () => {
// Object.defineProperty(ZoweUSSNode.prototype, "getAttributes", { value: new Error("Failed to update attributes"), configurable: true });
const getAttributesMock = jest.spyOn(ZoweUSSNode.prototype, "getAttributes").mockRejectedValue(new Error("Failed to update attributes"));
getAttributesMock.mockRejectedValue(attrError);
await (view as any).onDidReceiveMessage({
command: "update-attributes",
attrs: { owner: "someowner" },
Expand Down

0 comments on commit d55b15c

Please sign in to comment.