forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Dev tools console autocomplete issue opensearch-project#5567 (op…
…ensearch-project#5568) (opensearch-project#5614) * fix: Dev tools console autocomplete issue opensearch-project#5567 * Added CHANGELOG * Added test for retrieveAutoCompleteInfo * Refactored tests * Added suggested changes. --------- (cherry picked from commit a5c45a3) Signed-off-by: Kishor Rathva <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
60247dd
commit 561ca46
Showing
4 changed files
with
162 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/plugins/console/public/lib/opensearch/http_response.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { HttpFetchOptionsWithPath, HttpResponse } from '../../../../../core/public'; | ||
|
||
export const createMockResponse = ( | ||
statusCode: number, | ||
statusText: string, | ||
headers: Array<[string, string]> | ||
): Response => { | ||
return { | ||
headers: new Headers(headers), | ||
ok: true, | ||
redirected: false, | ||
status: statusCode, | ||
statusText, | ||
type: 'basic', | ||
url: '', | ||
clone: jest.fn(), | ||
body: (jest.fn() as unknown) as ReadableStream, | ||
bodyUsed: true, | ||
arrayBuffer: jest.fn(), | ||
blob: jest.fn(), | ||
text: jest.fn(), | ||
formData: jest.fn(), | ||
json: jest.fn(), | ||
}; | ||
}; | ||
|
||
export const createMockHttpResponse = ( | ||
statusCode: number, | ||
statusText: string, | ||
headers: Array<[string, string]>, | ||
body: any | ||
): HttpResponse<any> => { | ||
return { | ||
fetchOptions: (jest.fn() as unknown) as Readonly<HttpFetchOptionsWithPath>, | ||
request: (jest.fn() as unknown) as Readonly<Request>, | ||
response: createMockResponse(statusCode, statusText, headers), | ||
body, | ||
}; | ||
}; |