-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: Dev tools console autocomplete issue #5567 * Added CHANGELOG * Added test for retrieveAutoCompleteInfo * Refactored tests * Added suggested changes. --------- Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
- Loading branch information
Showing
5 changed files
with
163 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
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, | ||
}; | ||
}; |