Skip to content

Commit

Permalink
BaseProvider._handleError test cases
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 Oct 21, 2024
1 parent 91c8d65 commit 656036c
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as vscode from "vscode";
import { BaseProvider, ConflictViewSelection, DirEntry, FileEntry, ZoweScheme } from "../../../src/fs";
import { Gui } from "../../../src/globals";
import { MockedProperty } from "../../../__mocks__/mockUtils";
import { ErrorCorrelator, ZoweExplorerApiType } from "../../../src";

function getGlobalMocks(): { [key: string]: any } {
return {
Expand Down Expand Up @@ -542,6 +543,35 @@ describe("_handleConflict", () => {
expect(diffOverwriteMock).toHaveBeenCalledWith(globalMocks.testFileUri);
});
});
describe("_handleError", () => {
it("calls ErrorCorrelator.displayError to display error to user - no options provided", async () => {
const displayErrorMock = jest.spyOn(ErrorCorrelator.prototype, "displayError").mockReturnValue(new Promise((res, rej) => {}));
const prov = new (BaseProvider as any)();
prov._handleError(new Error("example"));
expect(displayErrorMock).toHaveBeenCalledWith(ZoweExplorerApiType.All, new Error("example"), {
additionalContext: undefined,
allowRetry: false,
profileType: "any",
templateArgs: undefined,
});
});
it("calls ErrorCorrelator.displayError to display error to user - options provided", async () => {
const displayErrorMock = jest.spyOn(ErrorCorrelator.prototype, "displayError").mockReturnValue(new Promise((res, rej) => {}));
const prov = new (BaseProvider as any)();
prov._handleError(new Error("example"), {
additionalContext: "Failed to list data sets",
apiType: ZoweExplorerApiType.Mvs,
profileType: "zosmf",
templateArgs: {},
});
expect(displayErrorMock).toHaveBeenCalledWith(ZoweExplorerApiType.Mvs, new Error("example"), {
additionalContext: "Failed to list data sets",
allowRetry: false,
profileType: "zosmf",
templateArgs: {},
});
});
});

describe("_relocateEntry", () => {
it("returns early if the entry does not exist in the file system", () => {
Expand Down

0 comments on commit 656036c

Please sign in to comment.