Skip to content

Commit

Permalink
Attempt to increase coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew W. Harn <[email protected]>
  • Loading branch information
awharn committed Nov 14, 2024
1 parent 612fa81 commit 731f7f7
Showing 1 changed file with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3803,10 +3803,18 @@ describe("Dataset Actions Unit Tests - function search", () => {
searchString,
},
];
const tokenCancellation: vscode.CancellationToken = {
isCancellationRequested: false,
onCancellationRequested: jest.fn(),
};
const myProgress = { test: "test" };

showInputBoxSpy.mockResolvedValue(searchString);
withProgressSpy.mockResolvedValue(expectedResponse);
withProgressSpy.mockImplementation((opts: any, fn: any) => {
return fn(myProgress, tokenCancellation);
});
getSearchMatchesSpy.mockReturnValue(expectedMatches);
performSearchSpy.mockResolvedValue(expectedResponse);

await DatasetActions.search(context, node);

Expand All @@ -3822,7 +3830,7 @@ describe("Dataset Actions Unit Tests - function search", () => {

expect(getSearchMatchesSpy).toHaveBeenCalledWith(node, expectedResponse, true, searchString);

expect(performSearchSpy).not.toHaveBeenCalled();
expect(performSearchSpy).toHaveBeenCalledTimes(1);
expect(openSearchAtLocationSpy).not.toHaveBeenCalled();

expect(tableBuilderTitleSpy).toHaveBeenCalledWith('Search Results for "test"');
Expand Down Expand Up @@ -3933,9 +3941,18 @@ describe("Dataset Actions Unit Tests - function search", () => {
},
];

const tokenCancellation: vscode.CancellationToken = {
isCancellationRequested: false,
onCancellationRequested: jest.fn(),
};
const myProgress = { test: "test" };

showInputBoxSpy.mockResolvedValue(searchString);
withProgressSpy.mockResolvedValue(expectedResponse);
withProgressSpy.mockImplementation((opts: any, fn: any) => {
return fn(myProgress, tokenCancellation);
});
getSearchMatchesSpy.mockReturnValue(expectedMatches);
performSearchSpy.mockResolvedValue(expectedResponse);

await DatasetActions.search(context, pdsNode);

Expand All @@ -3951,7 +3968,7 @@ describe("Dataset Actions Unit Tests - function search", () => {

expect(getSearchMatchesSpy).toHaveBeenCalledWith(pdsNode, expectedResponse, false, searchString);

expect(performSearchSpy).not.toHaveBeenCalled();
expect(performSearchSpy).toHaveBeenCalledTimes(1);
expect(openSearchAtLocationSpy).not.toHaveBeenCalled();

expect(tableBuilderTitleSpy).toHaveBeenCalledWith('Search Results for "test"');
Expand Down Expand Up @@ -4038,9 +4055,18 @@ describe("Dataset Actions Unit Tests - function search", () => {
},
];

const tokenCancellation: vscode.CancellationToken = {
isCancellationRequested: false,
onCancellationRequested: jest.fn(),
};
const myProgress = { test: "test" };

showInputBoxSpy.mockResolvedValue(searchString);
withProgressSpy.mockResolvedValue(expectedResponse);
withProgressSpy.mockImplementation((opts: any, fn: any) => {
return fn(myProgress, tokenCancellation);
});
getSearchMatchesSpy.mockReturnValue(expectedMatches);
performSearchSpy.mockResolvedValue(expectedResponse);

await DatasetActions.search(context, node);

Expand All @@ -4056,7 +4082,7 @@ describe("Dataset Actions Unit Tests - function search", () => {

expect(getSearchMatchesSpy).toHaveBeenCalledWith(node, expectedResponse, true, searchString);

expect(performSearchSpy).not.toHaveBeenCalled();
expect(performSearchSpy).toHaveBeenCalledTimes(1);
expect(openSearchAtLocationSpy).not.toHaveBeenCalled();

expect(tableBuilderTitleSpy).toHaveBeenCalledWith('Search Results for "test"');
Expand Down Expand Up @@ -4106,6 +4132,7 @@ describe("Dataset Actions Unit Tests - function search", () => {
expect(tableViewProviderSpy).toHaveBeenCalledTimes(1);
expect(tableViewProviderSetTableViewMock).toHaveBeenCalledTimes(1);
});

it("should attempt to perform the search (favorited pds node)", async () => {
const profile = createIProfile();
const node = createDatasetSessionNode(createISession(), profile);
Expand Down Expand Up @@ -4168,9 +4195,18 @@ describe("Dataset Actions Unit Tests - function search", () => {
},
];

const tokenCancellation: vscode.CancellationToken = {
isCancellationRequested: false,
onCancellationRequested: jest.fn(),
};
const myProgress = { test: "test" };

showInputBoxSpy.mockResolvedValue(searchString);
withProgressSpy.mockResolvedValue(expectedResponse);
withProgressSpy.mockImplementation((opts: any, fn: any) => {
return fn(myProgress, tokenCancellation);
});
getSearchMatchesSpy.mockReturnValue(expectedMatches);
performSearchSpy.mockResolvedValue(expectedResponse);

await DatasetActions.search(context, pdsNode);

Expand All @@ -4186,7 +4222,7 @@ describe("Dataset Actions Unit Tests - function search", () => {

expect(getSearchMatchesSpy).toHaveBeenCalledWith(pdsNode, expectedResponse, false, searchString);

expect(performSearchSpy).not.toHaveBeenCalled();
expect(performSearchSpy).toHaveBeenCalledTimes(1);
expect(openSearchAtLocationSpy).not.toHaveBeenCalled();

expect(tableBuilderTitleSpy).toHaveBeenCalledWith('Search Results for "test"');
Expand Down

0 comments on commit 731f7f7

Please sign in to comment.