Skip to content

Commit 0a18915

Browse files
committed
Update tests.
1 parent 035dff5 commit 0a18915

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/templates/core/node/getRequestBody.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
44
}
55
if (options.body) {
66
if (isString(options.body) || isBinary(options.body)) {
7-
return options.body;
7+
return options.body as BodyInit;
88
} else {
99
return JSON.stringify(options.body);
1010
}

src/templates/core/node/request.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ import { OpenAPI } from './OpenAPI';
5757
* @returns ApiResult
5858
* @throws ApiError
5959
*/
60-
export async function request(options: ApiRequestOptions): Promise<ApiResult> {
60+
export async function request(options: ApiRequestOptions, context: any): Promise<ApiResult> {
6161
const url = getUrl(options);
6262

6363
// Pre-hook on request if a function is provided.
6464
const requestHookResult = OpenAPI.REQUEST_HOOK ?
65-
(await OpenAPI.REQUEST_HOOK({ url, options})) : { url, options };
65+
(await OpenAPI.REQUEST_HOOK({ url, options, context})) : { url, options };
6666

6767
const response = await sendRequest(requestHookResult.options, requestHookResult.url);
6868
const responseBody = await getResponseBody(response);
6969
const responseHeader = getResponseHeader(response, requestHookResult.options.responseHeader);
7070

71-
const result: ApiResult = {
71+
let result: ApiResult = {
7272
url,
7373
ok: response.ok,
7474
status: response.status,
@@ -77,7 +77,7 @@ export async function request(options: ApiRequestOptions): Promise<ApiResult> {
7777
};
7878

7979
// Post-request Hook if provided
80-
result = OpenAPI.RESPONSE_HOOK ? await OpenAPI.RESPONSE_HOOK({url, result, response}) : result;
80+
result = OpenAPI.RESPONSE_HOOK ? await OpenAPI.RESPONSE_HOOK({url, result, response, context}) : result;
8181

8282
catchErrors(options, result);
8383
return result;

test/__snapshots__/index.spec.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function isStringWithValue(value: any): value is string {
126126
}
127127

128128
function isBlob(value: any): value is Blob {
129-
return value instanceof Blob;
129+
return value.constructor.name === 'Blob'
130130
}
131131

132132
function getQueryString(params: Record<string, any>): string {
@@ -2458,7 +2458,7 @@ function isStringWithValue(value: any): value is string {
24582458
}
24592459

24602460
function isBlob(value: any): value is Blob {
2461-
return value instanceof Blob;
2461+
return value.constructor.name === 'Blob'
24622462
}
24632463

24642464
function getQueryString(params: Record<string, any>): string {

0 commit comments

Comments
 (0)