diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSAttributeView.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSAttributeView.unit.test.ts index a409f3e67..6e2e2a3d1 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSAttributeView.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSAttributeView.unit.test.ts @@ -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({ @@ -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, @@ -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" }); @@ -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" },