Skip to content

Commit

Permalink
tests: add case for multiple resources
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Nov 18, 2024
1 parent b9c6717 commit 058b173
Showing 1 changed file with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ describe("Shared utils unit tests - function parseFavorites", () => {
describe("Shared utils unit tests - function addToWorkspace", () => {
it("adds a Data Set resource to the workspace", () => {
const datasetNode = new ZoweDatasetNode({
label: "EXAMPLE.DS",
collapsibleState: vscode.TreeItemCollapsibleState.None,
contextOverride: Constants.DS_DS_CONTEXT,
label: "EXAMPLE.PDS",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextOverride: Constants.DS_PDS_CONTEXT,
profile: createIProfile(),
});
const updateWorkspaceFoldersMock = jest.spyOn(vscode.workspace, "updateWorkspaceFolders").mockImplementation();
Expand All @@ -580,6 +580,34 @@ describe("Shared utils unit tests - function addToWorkspace", () => {
SharedUtils.addToWorkspace(ussNode, null as any);
expect(updateWorkspaceFoldersMock).toHaveBeenCalledWith(0, null, { uri: ussNode.resourceUri, name: `[sestest] ${ussNode.fullPath}` });
});
it("adds multiple resources to the workspace at once", () => {
const datasetNode1 = new ZoweDatasetNode({
label: "EXAMPLE.PDS1",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextOverride: Constants.DS_PDS_CONTEXT,
profile: createIProfile(),
});
const datasetNode2 = new ZoweDatasetNode({
label: "EXAMPLE.PDS2",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextOverride: Constants.DS_PDS_CONTEXT,
profile: createIProfile(),
});
const updateWorkspaceFoldersMock = jest.spyOn(vscode.workspace, "updateWorkspaceFolders").mockImplementation();
SharedUtils.addToWorkspace(null as any, [datasetNode1, datasetNode2]);
expect(updateWorkspaceFoldersMock).toHaveBeenCalledWith(
0,
null,
{
uri: datasetNode1.resourceUri,
name: `[sestest] ${datasetNode1.label as string}`,
},
{
uri: datasetNode2.resourceUri,
name: `[sestest] ${datasetNode2.label as string}`,
}
);
});
it("adds a USS session w/ fullPath to the workspace", () => {
const ussNode = new ZoweUSSNode({
label: "sestest",
Expand Down Expand Up @@ -617,9 +645,9 @@ describe("Shared utils unit tests - function addToWorkspace", () => {
});
it("skips adding a resource that's already in the workspace", () => {
const ussNode = new ZoweUSSNode({
label: "textFile.txt",
label: "testFolder",
collapsibleState: vscode.TreeItemCollapsibleState.None,
contextOverride: Constants.USS_TEXT_FILE_CONTEXT,
contextOverride: Constants.USS_DIR_CONTEXT,
profile: createIProfile(),
});
const workspaceFolders = new MockedProperty(vscode.workspace, "workspaceFolders", {
Expand Down

0 comments on commit 058b173

Please sign in to comment.